How do I pass raw strings to commands through the command line in PowerShell?
command-prompt, powershell
Solution
If you are using Powershell v3.0, there is a new syntax to make Powershell avoid any extra parsing for arguments. Something like:
inventory.exe --% 'inventory', 'date', 'owner'
There are other approaches as mentioned here: http://blogs.technet.com/b/josebda/archive/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters.aspx
Problem
Our IT department is moving to Windows 8 and everyone is starting to use PowerShell as their default windows command line environment rather than the `cmd.exe`. Unfortunately PowerShell evaluates the things you type in it and it's quite hard to pass raw command line arguments to programs. For example I've a program `inventory.exe` that takes a special string that formats its output. I can't pass this special string in PowerShell as I get a mysterious error: ``` PS C:\Users\Administrator> inventory.exe 'inventory "," date "," owner' inventory.exe error: No comma allowed ``` I assume that PowerShell evaluated the `'inventory "," date "," owner'` string somehow and something else was passed to `inventory.exe` program as a result it printed an error. This program works ok in `cmd.exe`: ``` C:\Documents and Settings\boda> inventory.exe 'inventory "," date "," owner' ... (the output that I expect) ... ``` It even gets worse if I type characters such as `%`, `$` in PowerShell. Does anyone know how to pass raw strings to commands in PowerShell?