Q. What is Windows PowerShell’s escape character, and how is it used?

A. PowerShell uses the back tick (`) as its escape character. On a US keyboard, it appears in the upper-left of the main keys, next to the 1. It's on the same key as the tilde (~) character. Depending on the font you’re using, the back tick can be tough to distinguish from a single quote, so be careful!

In most cases, the back tick removes the “specialness” of any character. For example, PowerShell uses spaces as a separator in commands. That means parameters that contain spaces must normally be enclosed in quotation marks:

Dir "c:\program files"

An alternative is to escape the space character, making it a literal character:

Dir c:\program` files
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish