Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The start-process cmdlet of powershell will fail with -PassThru argument when trying to launch Edge browser

In my test script by powershell, I'd start an Edge browser and get it's main process's ID. Simply like this:

$edge = Start-Process microsoft-edge: www.ted.com -PassThru

but instead of able to get the process id from $edge.Id, I've got error message like this:

Start-Process : This command cannot be run completely because the system cannot find all the information required.
At line:1 char:7
+ $edge=Start-Process microsoft-edge: www.ted.com -PassThru
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

Is there any simple and straightforward way to really doing this without enumerate and check the process list?

Thanks!

like image 566
Weishan Yang Avatar asked Jan 24 '26 09:01

Weishan Yang


1 Answers

I try to test your script and I am getting a similar error as yours.

Based on my search result, passthru is not one of the common parameters, and it does not exist everywhere.

Reference:

Use the PowerShell Passthru Parameter and Get Back Objects

I think it is not available for the MS Edge browser and that's why the script gives an error.

I try to search for an alternative command for PassThru but I did not get any helpful information about it.

In this situation, it is better to enumerate and check the process list

like image 66
Deepak-MSFT Avatar answered Jan 26 '26 03:01

Deepak-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!