4

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!

Weishan Yang
  • 428
  • 2
  • 5
  • 15
  • 1
    https://stackoverflow.com/questions/57053312/how-to-open-edge-using-powershell-variable – f6a4 Jan 07 '20 at 15:49
  • Thanks for your quick answer, but that didn't resolved my problem. In my case, the edge browser does started, only that the process object is not granted for been referenced by the variable. Using explorer.exe or cmd.exe would not give the error message, but you'll get the process id for the launcher instead of the browser been launched. Any other idea is welcome. – Weishan Yang Jan 07 '20 at 16:01

1 Answers1

1

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

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • 1
    Ha, thanks for your reply and looking into this. I've noticed that the problem seems to be with the metro apps. I've tried the command with the calculator: Start-Process calculator: -PassThru and got the same kind of outcome. So, you work for MSFT? Looking forward for Microsoft to have this kind of problem fixed then. Regards, – Weishan Yang Jan 09 '20 at 08:29
  • 1
    MS Edge browser is the UWP app that do not launch like other .EXE file and as I informed you PassThru is not available for all the applications. So this can be the reason that it is not working. – Deepak-MSFT Jan 09 '20 at 08:52
  • tks, that passtru doesn't exist for Windows Explorer too, when start-proces a folder path – Dee Jul 20 '23 at 07:33