Caleb Jares Caleb Jares - 1 year ago 72
PowerShell Question

Can I use a single quote in a Powershell 'string'?

I want to include an apostrophe in my string. Is it possible to do without using double quotes?

'This is a quote. Can`'t I just include a single quote in it?'
'This is another quote that doesn\'t work'

Answer Source
'Escape a single quote '' using a double single quote'

See the help for the quoting rules.

You can check out the help in the powershell command line by typing:

Get-Help about_Quoting_Rules

It explains that backticks are interpreted literally in single-quoted strings.

Because the contents of single-quoted strings are interpreted literally, you cannot use the backtick character to force a literal character interpretation in a single-quoted string.