Powershell Start-Process Parameter Problems

parameterspowershell

Probably a total noob question but:

When I run

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

I get the error

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

But all of:

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

Work fine… what am I missing??

Best Answer

Get-Command -syntax Start-Process

gives two entries (manual wrapping added, and removing common parameters):

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>]

In your working cases specifying either -RedirectStandardOutput or -WindowStyle uniquely identifies which parameter set to use.

In your non-working case you have both of these parameters, but there is no parameter set that has both, hence PSH can't select one.

Related Question