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

PowershellEscaping

Powershell Problem Overview


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'

Powershell Solutions


Solution 1 - Powershell

'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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCaleb JaresView Question on Stackoverflow
Solution 1 - PowershellzdanView Answer on Stackoverflow