11

I have tried the following:

$edge = New-Object -com microsoft-edge.application
$edge.visible = $true
$edge.FullScreen = $true

But I get error:

New-Object : Retrieving the COM class factory for component with CLSID 
{00000000-0000-0000-0000-000000000000} failed
due to the following error: 80040154 Class not registered (Exception from 
HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:1 char:9
+ $edge = New-Object -com microsoft-edge.application
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

Am I doing something obviously wrong here?

Edit 17/07/2019 - I have changed to below:

$edge = Start-Process -FilePath ($Env:WinDir + "\explorer.exe") 
-ArgumentList 
"shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"
$edge.visible = $true
$edge.FullScreen = $true

So now Edge opens but the Visible and Fullscreen commands return errors - anyone have any ideas?

Cheers

4
  • has edge been run at least once by that account on that system? Commented Jul 16, 2019 at 9:01
  • 6
    Edge is not automatable in that way - see stackoverflow.com/questions/31302304/… Commented Jul 16, 2019 at 9:01
  • Hi @Lee_Dailey Yes it has been run before Commented Jul 16, 2019 at 14:15
  • @Naz - isee that TessellatingHeckler has the answer ... you can't do that in that manner. [grin] Commented Jul 16, 2019 at 14:22

3 Answers 3

9

I think this might be the solution:

start microsoft-edge:http://google.com
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Google - Microsoft Edge')
Sleep 2
$wshell.SendKeys('{F11}')

I found the above code here:start microsoft edge in fullscreen

You can send edge different keys depending on what you want: How to send CTRL or ALT + any other key?

You could find the key shortcut to whatever you want to do to the Edge window.

You could try this(source is link below):

Start-Process -FilePath ($Env:WinDir + "\explorer.exe") -ArgumentList "shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge"

There is also a way to open it in Incognito Mode:

How to start Microsoft Edge in private mode by PowerShell

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for this, I tried it and it works to open it. However, the Fullscreen and Visible commands still return errors - any ideas?
Actually, while looking this up, since I had no idea, I found a better solution. I'll add it to my answer
For me, the Sleep command before issuing seemed to help.
6

You could use the following command to open Microsoft Edge browser and navigate to the special URL.

start microsoft-edge:http://google.com

Edit:

If you want to use Edge Webdriver to open IE browser, you could download the Edge webdriver from this link, and refer to this article to use it.

Comments

3

The existing answers may work for some environments, BUT they are not guaranteed since they use the alias start instead of the Start-Process command directly.

It is best to use the command directly in scripts.


Open Edge full screen:

Start-Process microsoft-edge: -WindowStyle maximized

Explanation

The Start-Process command is executed on microsoft-edge, with the argument -WindowStyle set to maximized. This will open edge and maximize it to full screen.


Open Edge full screen AND navigate to specified webpage:

Start-Process microsoft-edge:https://stackoverflow.com -WindowStyle maximized

Explanation

Like before, the Start-Process command is executed on microsoft-edge and the : specifies to open https://stackoverflow.com. The argument -WindowStyle set to maximized will full screen Edge and load stackoverflow.com.


Official documentation: Start-Process

3 Comments

How can I control whether the tab opens in a new window or not? When I leave the URL blank it opens in a new window Start-Process microsoft-edge: -WindowStyle maximized , but when I add a URL (like this answer) it opens in a previous window. I want to force it to open in a new window.
Update on previous comment, leaving the URL blank (: followed by nothing) the script errors out with a NullArgumentException... which suggests the opening in a new window is an accident. How can I intentionally do this then?
How to open an extension page using Start-Process script? I tried using extension:// and chrome-extension:// but neither worked. Basically, I want to open non-http urls from powershell script inside edge browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.