December 10th, 2015

PowerTip: Escape Parsed Content in PowerShell String

Doctor Scripto
Scripter

Summary: Use the backtick character to insert data normally parsed by Windows PowerShell in a string.

Hey, Scripting Guy! Question Certain characters (such as the colon and double quotation marks) are special in Windows PowerShell.
           How can I use those in a parsed string?

Hey, Scripting Guy! Answer Use the backtick character (usually under the tilde, and it’s also ASCII character 96), for example:

$OSDrive=’C’

$DriveLetter=”$OSDrive`:”

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.