PowerTip: Escape Parsed Content in PowerShell String

Doctor Scripto

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`:”

0 comments

Discussion is closed.

Feedback usabilla icon