powershellescapingrawstring

How can I save strings as raw data in Powershell?


I would like to set a string with special chars in it ($ for example). How can I save a string as a raw string?

$B = "A$$B" isn't saved as "A$$B".


Solution

  • If the string is in ' (single quotes) the variables ( like $x ) are not expanded.

    Also, Powershell has here-strings much like verbatim strings in C#

    http://blogs.msdn.com/b/powershell/archive/2006/07/15/variable-expansion-in-strings-and-herestrings.aspx