July 28th, 2015

PowerTip: Read File with Backtick in Name

Doctor Scripto
Scripter

Summary: Read the content of a text file with a backtick ( ` ) in the name.

Hey, Scripting Guy! Question How can I use Windows PowerShell to read the content of a file that has a backtick ( ` ) in the file name?

Hey, Scripting Guy! Answer Use single quotation marks around the name when you supply the path to Get-Content, for example:

Get-Content 'c:\fso\a file with a `in the name.txt'

The following examples fail:

Get-Content "c:\fso\a file with a `in the name.txt"

Get-Content c:\fso\a file with a `in the name.txt

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.