Cannot process argument transformation


Inspired by this post, I created the script below DOSCommands.ps1

However, on execution it returns this error:

I’ve searched for this error but can’t figure it out. It seems to me that it can’t convert the string type correctly! Please help!


Your best bet is to use --% in PowerShell V3 or higher. See this blog post I wrote on using --%. In V1/V2 the situation is just bad as you can see in this Connect bug on the issue. The common workaround in V1/V2 is to use Start-Process or .NET’s Process.Start. From those list of workarounds, I kind of like this one:

Which is effectively what --% does to the parsing of all parameters following it i.e. it parses them in a dumbed down mode similar to cmd.exe parameter parsing including expanding env vars referenced with %envVarName%.


Cannot process argument transformation by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply