PowerShell stripping double quotes from command line arguments

It is a known thing:

It’s FAR TOO HARD to pass parameters to applications which require quoted strings. I asked this question in IRC with a “roomful” of PowerShell experts, and it took hour for someone to figure out a way (I originally started to post here that it is simply not possible). This completely breaks PowerShell’s ability to serve as a general purpose shell, because we can’t do simple things like executing sqlcmd. The number one job of a command shell should be running command-line applications… As an example, trying to use SqlCmd from SQL Server 2008, there is a -v parameter which takes a series of name:value parameters. If the value has spaces in it, you must quote it…

…there is no single way to write a command line to invoke this application correctly, so even after you master all 4 or 5 different ways of quoting and escaping things, you’re still guessing as to which will work when … or, you can just shell out to cmd, and be done with it.

Leave a Comment