4

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

JimmyP
  • 165
  • 1
  • 5

1 Answers1

6
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.

Richard
  • 8,952
  • 3
  • 26
  • 27
  • Ahhh I see. Thanks... so no way to run in a hidden window and redirect output then huh? – JimmyP May 09 '11 at 11:35
  • @JimmyP: Not with the cmdlet (directly using [System.Diagnostics.Process] will allow more control, but unclear how easy to to the redirection at that level in PSH. Of course the combination of standard output and a GUI is pretty rare in Windows... – Richard May 09 '11 at 12:15