Changing the default browser in Windows 11 using a PowerShell script.

Tzahi Kolber
3 min readDec 19, 2023

Changing the default browser in Windows 10 and Windows 11 isn’t simple like changing the registry values, since from Windows 10 they are protected with a hash.
One of the options are using a group policy which sometimes can be complex, especially when you are using a non-managed environment, like some cloud environments.

The simplest solution of all…

Well… one of the PowerShell magics are simulating a user interactions like TAB, Enter, Down arrow, etc:
$shell.SendKeys(‘{TAB}’)
In addition, of course you can also type a simple text:
$shell.SendKeys(“edge”)
By using those capabilities, we can open the Windows settings (Start-Process ms-settings:defaultapps) and simulate the user’s actions in order to change the default browser.

You have already the main 3 most common browsers options:

  • Microsoft Edge.
  • Mozilla Firefox.
  • Google Chrome.

Notice!
You must have the default browser you would like to set, already installed on your computer.

By the way, you can add different browsers options to the script and change the default accordingly.
For example, if you want to add the option to choose Brave as your default browser, verify that the browser is installed and add the next two lines:

# Set Brave as a default browser
$shell.SendKeys(“brave”); Start-Sleep -seconds 1

Option #1: Running a simple script, according to your choice.

In this method, you are simply running the script, to change the default browser.
You can run it as a logon script or in any other option you choose.

The script is set by default to set the default browser to EGDE:

The default state of the default browser — set to EDGE

To change the default browser’s configuration, all you need to do, is to add the # sign before the current setting browser and remove the # sign next to the browser you would like to set as the default.

For example, in case you would like to set the default browser from Microsoft’s Edge to Mozilla Firefox, we need to add the # sign before the Edge raw selection and remove the # sign before the Firefox raw:

Changing the default browser selection to Firefox from EDGE

Download the Script: Set-default-browser-W11.ps1

Option #2: Running the script as a function, according to your choice (easier editing…)

In this method, you can run function with the selected browser at the same command, to set the default browser.
For example, to set the default browser to Firefox from Edge, just change the last raw of the script from Edge to Firefox and run the script:

Setting the default browser to Firefox

Setting the default browser back to Edge:

Setting the default browser to EDGE

Download the Script: set-default-browser-W11-function.ps1

Hope that helps :-)

--

--

Tzahi Kolber

During the last 15 years, I was working as a Senior PFE within Exchange area at Microsoft. Now I’m Senior Consult as Azure IAAS, PowerShell & Automations.