Search code examples
shellpowershellcommand-line-interfacequotesquoting

The term 'Win32' is not recognized as the name of a cmdlet - pass a pipe symbol as part of an argument


I'm trying to make script for automate build's. Stacked on "release|Win32" command

Command:

PS C:\Users\Builder> powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com'" C:\Build\
VS2012Build\3.2.7X\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean Release|Win32 No Local

Error:

The term 'Win32' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spell
ing of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:193
+ powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com'" C:\Build\VS2012Build\3.2.7X
\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean Release|Win32 <<<<  No Local
    + CategoryInfo          : ObjectNotFound: (Win32:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Solution

  • Since | is a metacharacter (a character with syntactic meaning) in PowerShell, you must quote it if you want to use it as part of an argument - either individually with ` or, more typically, by (single- or double-)quoting the entire argument:

    powershell.exe "& 'C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.com' C:\Build\VS2012Build\3.2.7X\ClientServer\SHClientServer\SHCApplicationsVS2012.sln /Clean 'Release|Win32' No Local"
    
    • Note how Release|Win32 is now single-quoted ('Release|Win32').
    • Also, I've enclosed the entire PowerShell command in "..." for robustness.