It has to be said that if you blink, then you will miss the ` backtick. However, it would be a pity if did, because backtick a
llows you to word-wrap PowerShell commands.
When you write code for any scripting language there comes a time when you want the command to wrap onto the next line. PowerShell, along with most languages, regards the end-of-line character as
the end of that command. Consequently, a new line means the start of a new command. Thus we have established the need for a command to tell PowerShell that this command wraps to the next line -
enter the tiny backtick `.
On my
UK keyboard the backtick is on the
top row next to '1' key. It's the key above the Tab and below the Esc key. My key has three symbols, ` ¬ ¦ All you need to get the backtick is press the key on its own
without holding down the shift or the Alt key.
As you can see, unless I use the smallest font, it won't all fit on one line, consequently we need to tell PowerShell to word-wrap. More importantly, most script editors issue an end-of-line
marker before they reach 86 characters.
Challenge: There is a ` backtick after ServiceType, but can you spot a second backtick?
It is important to distinguish the primary use of the backtick, on its own `, and its secondary use as an escape character, for example, backtick with
`n or `t . Let me explain with an example.
2a) Write-host "Heading Sub Heading"
Problem: undesired result
Heading Sub Heading
Solution: Add the crucial `n
2b) Write-host "Heading `nSub Heading"
Result: Desired result achieved
Heading Sub Heading
Note 1: Remember that the escape family `n, `r and `t work within "text" rather than within command statements.
Take the time to seek out the `backtick key. One day it will help you to word-wrap your commands. There may also be work for the rest of the backtick family, for example `t to align an output
column with a tab.
If you see an error of any kind, do let me know. Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.