Wednesday, 22 July 2015

PowerShell and (not) parsing command lines

A short reminder note for myself.

To tell PowerShell to not parse the remainder of a line, use --%. This is invaluable when calling out to external commands and you don’t want to escape every special character with a backtick (`).

So instead of this:

icacls X:\VMS /grant Dom\HVAdmin:`(CI`)`(OI`)F

You can write this:

icacls X:\VMS --% /grant Dom\HVAdmin:(CI)(OI)F

See the Stop Parsing section in Online Help for more info.

1 comment:

Ben Laan said...

Yes! How did I not know this one...??