【发布时间】:2012-04-25 05:43:35
【问题描述】:
我想在 PowerShell 上执行一个 cmd,这个命令使用分号。然后 PowerShell 将其解释为多个命令。如何让 PowerShell 忽略分号并执行我的命令如何成为唯一的命令?
例子:
Invoke-Expression "msbuild /t:Build;PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Debug;_PackageTempDir=$TargetFolder $WebProject"
另一个例子:
Invoke-Expression "test`;test2"
第二个示例响应:
The term 'test' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:6
+ teste <<<< ;teste2
+ CategoryInfo : ObjectNotFound: (teste:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'test2' is not recognized as the name of a cmdlet, function, script file, or operable program. Chec
k the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:13
+ teste;teste2 <<<<
+ CategoryInfo : ObjectNotFound: (teste2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
【问题讨论】:
-
第二种情况
iex "test;test2"- 不需要转义分号。
标签: powershell