Prerequisites
Summary
Need to document the -AsLiteral switch for ConvertFrom-StringData cmdlet, which auto escapes input strings coming from pipeline.
Details
Currently if you want to escape strings before piping to ConvertFrom-StringData, you need to replace or escape beforehand:
> 'a=b\C' | ConvertFrom-StringData
ConvertFrom-StringData: Invalid pattern 'b\C' at offset 3. Unrecognized escape sequence \C.
> [Regex]::Escape('a=b\C') | ConvertFrom-StringData
Name Value
---- -----
a b\C
With the new -AsLiteral switch, it escapes input strings automatically:
'a=b\C' | ConvertFrom-StringData -AsLiteral
Name Value
---- -----
a b\C
Articles
- reference/7.4/Microsoft.PowerShell.Utility/ConvertFrom-StringData.md
Related Source Pull Requests
Related Source Issues
Prerequisites
Get-Foocmdlet" instead of "New cmdlet."Summary
Need to document the
-AsLiteralswitch forConvertFrom-StringDatacmdlet, which auto escapes input strings coming from pipeline.Details
Currently if you want to escape strings before piping to
ConvertFrom-StringData, you need to replace or escape beforehand:With the new
-AsLiteralswitch, it escapes input strings automatically:Articles
Related Source Pull Requests
-AsLiteralswitch toConvertFrom-StringDatacmdlet PowerShell/PowerShell#21007Related Source Issues
ConvertFrom-StringData-Raw switch to parse data field as literal PowerShell/PowerShell#20418