Start-up process gives an error

Here is 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 there is an 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 start the process in a hidden window, wait for it to return and get the error, output and exit code.

+8
powershell
source share
1 answer

According to the documentation for Start-Process, the combination of redirection parameters (RedirectStandardOutput and RedirectStandardError) and WindowStyle parameter is invalid because they exist in separate sets of parameters .

This means that they cannot be used together. That is why you get this particular error.

+11
source share

Source: https://habr.com/ru/post/650473/


All Articles