Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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".

like image 251
Alex58 Avatar asked Oct 18 '25 23:10

Alex58


2 Answers

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

like image 85
manojlds Avatar answered Oct 20 '25 13:10

manojlds


maybe you can use the ` to escape chars (called 'backquote')

like image 21
nabuchodonossor Avatar answered Oct 20 '25 13:10

nabuchodonossor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!