There are certain characters on the keyboard that no matter how you try, they just don’t appear in a text file.
Well actually they DO but we can’t tell WHAT they are. But there are times you need to reference those characters. Say if you’re trying to type in something meant to be echoed to two lines? Need to send a tab character?
Fortunately all of this is well documented online at Microsoft when working with Powershell . For those of you who remember DOS? (*ACK WHAT?!*) it will be the same technique when typing those special characters.
You just need a little thing called the “BackTick” —– > ` < —– and a few special letters
`f Form feed
`n New line
`r Carriage return
`t Horizontal tab
`v Vertical tab
Now a lot of us out there will neither know nor care what a “Vertical Tab” is (for the record it’s from back in the days of Consoles and Line printers) but the important thing to note is these characters are used in text files.
Sometimes you’ll get data and you need to clean it up (from say a Unix system?) and you’ll need to specify the character.
If you’re working with these special characters, the string information always has to be referenced in Double Quotes — > “ < —
will show up as
And if you were trying to searching for a “Tab” character in a “tab separated file” as an example you could do this now.
(GET-CONTENT FILENAME.TXT) –replace “`h”,” “
Not the best example but it does show you it’s not hard to work with. Also remember if you have any characters that are special (Like the Double or Single Quote) that NEED to be in a string, Put the BackTick ` before them to keep them included without problems (even the backtick itself)
BTW, this trick also works if you’re on Server 2008 Core. There are situations even there (like passwords) where certain characters need to be typed.
The Energized Tech