You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 7.4.0, it appears that the Group-Object cmdlet tries to interpret its string input as .NET format strings.
If a string contains curly braces (U+007B and U+007D), the Group-Object cmdlet throws exceptions associated with the [string]::Format method or the -f operator.
PS> '{' | Group-Object -NoElement;Group-Object: Input string was not in a correct format. Failure to parse near offset 1. Expected an ASCII digit.PS> '}' | Group-Object -NoElement;Group-Object: Input string was not in a correct format. Failure to parse near offset 1. Unexpected closing brace without a corresponding opening brace.
Error details
Exception : Type : System.FormatException TargetSite : Name : ThrowFormatInvalidString DeclaringType : System.ThrowHelper, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e MemberType : Method Module : System.Private.CoreLib.dll Message : Input string was not in a correct format. Failure to parse near offset 1. Unexpected closing brace without a corresponding opening brace. Source : System.Private.CoreLib HResult : -2146233033 StackTrace : at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args) at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at Microsoft.PowerShell.Commands.GroupInfo.BuildName(List`1 propValues) at Microsoft.PowerShell.Commands.GroupInfo..ctor(OrderByPropertyEntry groupValue) at Microsoft.PowerShell.Commands.GroupObjectCommand.DoOrderedGrouping(OrderByPropertyEntry currentObjectEntry, Boolean noElement, List`1 groups, Dictionary`2 groupInfoDictionary, OrderByPropertyComparer orderByPropertyComparer) at Microsoft.PowerShell.Commands.GroupObjectCommand.EndProcessing() at System.Management.Automation.CommandProcessorBase.Complete()CategoryInfo : NotSpecified: (:) [Group-Object], FormatExceptionFullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.Commands.GroupObjectCommandInvocationInfo : MyCommand : Group-Object ScriptLineNumber : 1 OffsetInLine : 7 HistoryId : 9 Line : '}' | Group-Object -NoElement; Statement : Group-Object -NoElement PositionMessage : At line:1 char:7 + '}' | Group-Object -NoElement; + ~~~~~~~~~~~~~~~~~~~~~~~ InvocationName : Group-Object CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
Name Value
---------
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
Since 7.4.0, it appears that the
Group-Objectcmdlet tries to interpret its string input as .NET format strings.If a string contains curly braces (U+007B and U+007D), the
Group-Objectcmdlet throws exceptions associated with the[string]::Formatmethod or the-foperator.Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response