Pretty simple question, I don’t see it listed yet.
$a = "`4Test `!User"
$a | Out-File test.txt
Output I want:
`4Test `!User"
Output I get:
4Test !User
>Solution :
Use single quotes instead of double quotes:
$a = '`4Test `!User'
$a
Output:
`4Test `!User
Explanation:
A string enclosed in double quotation marks is an expandable string. Variable names preceded by a dollar sign ($) are replaced with the variable’s value before the string is passed to the command for processing. for example:
$i = 5
"The value of $i is $i."
Output:
The value of 5 is 5.
A string enclosed in single quotation marks is a verbatim string. The
string is passed to the command exactly as you type it. No
substitution is performed. for example:
$i = 5
'The value of $i is $i.'
Output:
The value $i is $i.
for further information see: about_Quoting_Rules