'open HTML from PowerShell with URL parameters

I am trying to open a HTML file in Microsoft Edge browser from PowerShell.

Below code opens HTML in Microsoft edge

&'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' @('d:\test.html')

How to pass some values from PowerShell to HTML using URL parameters. I wanted something like below code

&'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' @('d:\test.html?testvalue1=45&testvalue2=50')

But the above code opens browser but cannot able to load test.html. Using JavaScript I want to get values from URL which is passed by PowerShell.



Solution 1:[1]

You could try the command below.

Start-Process microsoft-edge:"https://localhost?testvalue1=45&testvalue2=50"

Output:

enter image description here

Solution 2:[2]

One way to accomplish this is to use the "Start-Process" cmdlet

Start-Process 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe' C:\Web\index.html

This however only works if you know the path. For some reason Powershell fails to translate for example .\index.html to a proper path.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Deepak-MSFT
Solution 2 Encore