Reputation: 2226
I am invoking a powershell script from a batch file
powershell createshortcut.ps1 "%~n0"
However if the parameter has a single quote (expanded sample)
powershell createshortcut.ps1 "Divertirsi con l'ortografia"
the parser will throw an error
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
Obviously the parameter's content is unknown.
Powershell version:
Major Minor Build Revision
----- ----- ----- --------
5 1 14393 2189
Upvotes: 0
Views: 308
Reputation: 16266
Tell PowerShell that it will be processing a -File
rather than a -Command
.
powershell -NoProfile -File createshortcut.ps1 "Divertirsi con l'ortografia"
Upvotes: 2
Reputation: 472
Either escape it using a single backtick (`):
powershell createshortcut.ps1 "Divertirsi con l`'ortografia"
Or replace double-quotes by simple ones and use ''
:
powershell createshortcut.ps1 'Divertirsi con l''ortografia'
Upvotes: 0