Here's the code
$tool = "E:\Experiments\Popup\latest\xperf.exe"
$toolOutput = "XPerfOutput.log"
$toolError = "XPerfError.log"
$command = "-stop"
$x = Start-Process -FilePath $tool -ArgumentList $command -RedirectStandardOutput $toolOutput -RedirectStandardError $toolError -WindowStyle Hidden -PassThru -Wait
And Here's there error:
Start-Process : Parameter set cannot be resolved using the specified named parameters. At E:\Experiments\Popup\asd.ps1:9 char:1
+ Start-Process -FilePath $tool -ArgumentList $command -RedirectStandardOutput $toolOutput RedirectStandardError $toolError -WindowStyle Hidden
-PassThru -Wait
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand
I want to run the process in a hidden window, wait for it to return and get the error, output and exit code.
According to the documentation for Start-Process, the combination of the redirection parameters (RedirectStandardOutput and RedirectStandardError) and the WindowStyle parameter is invalid since they exist in separate parameter sets.
This means that they cannot be used together. This is why you're receiving that particular error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With