Jim*_*myP 4 powershell parameters
可能是一个完全的菜鸟问题,但是:
当我跑
Start-Process ".\packages\PS-Get.0.1.0.0\NuGet.exe" update -RedirectStandardOutput ".\packages\PS-Get.0.1.0.0\NuGet.exe.Update.log" -RedirectStandardError ".\packages\PS-Get.0.1.0.0\NuGet.exe.Update.log" -WindowStyle Hidden
Run Code Online (Sandbox Code Playgroud)
我收到错误
Start-Process : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:14
+ Start-Process <<<< ".\packages\PS-Get.0.1.0.0\NuGet.exe" update -RedirectStandardOutput ".\packages\
PS-Get.0.1.0.0\NuGet.exe.Update.log" -RedirectStandardError ".\packages\PS-Get.0.1.0.0\NuGet.exe.Update.log" -WindowStyle Hidden
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand
Run Code Online (Sandbox Code Playgroud)
但所有的:
Start-Process ".\packages\PS-Get.0.1.0.0\NuGet.exe" update -RedirectStandardOutput ".\packages\PS-Get.0.1.0.0\NuGet.exe.Update.log"
Start-Process ".\packages\PS-Get.0.1.0.0\NuGet.exe" update -RedirectStandardError ".\packages\PS-Get.0.1.0.0\NuGet.exe.Update.log"
Start-Process ".\packages\PS-Get.0.1.0.0\NuGet.exe" update -WindowStyle Hidden
Run Code Online (Sandbox Code Playgroud)
工作正常......我错过了什么?
Get-Command -syntax Start-Process
Run Code Online (Sandbox Code Playgroud)
给出两个条目(手动包装添加,并删除公共参数):
Start-Process [-FilePath] <String>
[[-ArgumentList] <String[]>]
[-Credential <PSCredential>]
[-WorkingDirectory <String>]
[-LoadUserProfile] [-NoNewWindow] [-PassThru]
[-RedirectStandardError <String>] [-RedirectStandardInput <String>]
[-RedirectStandardOutput <String>] [-Wait] [-UseNewEnvironment]
Start-Process [-FilePath] <String>
[[-ArgumentList] <String[]>]
[-WorkingDirectory <String>]
[-PassThru]
[-Verb <String>] [-Wait]
[-WindowStyle <ProcessWindowStyle>]
Run Code Online (Sandbox Code Playgroud)
在您的工作案例中,指定-RedirectStandardOutput或-WindowStyle唯一标识要使用的参数集。
在您的非工作情况下,您拥有这两个参数,但没有同时拥有这两个参数的参数集,因此 PSH 无法选择其中一个。
| 归档时间: |
|
| 查看次数: |
6908 次 |
| 最近记录: |