Skip to content

Document -AsLiteral switch for ConvertFrom-StringData cmdlet #10769

Open
@ArmaanMcleod

Description

@ArmaanMcleod

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Document new Get-Foo cmdlet" instead of "New cmdlet."

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions