Creating a Pretty Good Installer Script for Microsoft Edge

Here is a work in progress sample for a better installer script for Microsoft Edge. I'm still trying to figure out why the master_preferences file I create seem to be ignored, and I wanted to add in the update channel info that ConfigMgr automatically adds to its Edge installer script , but I haven't done that yet. Any comments/feedback/ideas are more than welcome 🙂

ConfigMgr Native Script for Edge

The native ConfigMgr script adds an update channel to the registry, so I added the autoupdate script snippet here for reference. I was planning on "borrowing" some of this logic for my own script, but wanted to learn more about the AutoUpdateValueName / EdgeUpdate registry options first.. Stay tuned (or comment if you have more info).

# Code for Stable Release, just removed the param block, and the msiexec portion
$ChannelID = "{56eb18f8-b008-4cbd-b6d2-8c97fe7e9062}"

# Registry value name is in the format "Update<{ChannelID}> where ChannelID is the GUID
Set-Variable -Name "AutoUpdateValueName" -Value "Update$ChannelID" -Option Constant
Set-Variable -Name "RegistryPath" -Value "HKLM:\SOFTWARE\Policies\Microsoft\EdgeUpdate" -Option Constant

# Test if the registry key exists. If it doesn't, create it
$EdgeUpdateRegKeyExists = Test-Path -Path $RegistryPath

if (!$EdgeUpdateRegKeyExists)
    New-Item -Path $RegistryPath

# See if the autoupdate value exists
if (!(Get-ItemProperty -Path $RegistryPath -Name $AutoUpdateValueName -ErrorAction SilentlyContinue))
    New-ItemProperty -Path $RegistryPath -Name $AutoUpdateValueName -Value 0 -PropertyType DWord

The Script

Below is what I come up with so far, and as mentioned previously the master_preferences file seem not to work…

# Script for installing Microsoft Edge using MDT 
# Author: Johan Arwidmark (@jarwidmark on Twitter)

# Figure out where the script is started from, works when using F8 in PowerShell ISE too :)
$ScriptDir = $MyInvocation.MyCommand.Path
if (-Not $ScriptDir) {
    $ScriptDir = $psISE.CurrentFile.Fullpath
if ($ScriptDir) {
    $ScriptDir = Split-Path $ScriptDir -Parent

Function TimeStamp {$(Get-Date -UFormat "%D %T")} 

# Figuring out where to save the log files
# If MDT Task Sequence environment is found, log to default MDT log file location
# If no MDT environment is found, log to C:\Windows\Temp
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $LogFile = "$($tsenv.Value("LogPath"))\Install-MicrosoftEdge.log"
    $MSILogFile = "$($tsenv.Value("LogPath"))\Install-MicrosoftEdgeMS"

    # No MDT environment found
    $LogFile = "C:\Windows\Temp\Install-MicrosoftEdge.log"
    $MSILogFile = "C:\Windows\Temp\Install-MicrosoftEdgeMS"

# Setup variables
$SetupName = "Microsoft Edge"
$SetupFile = "msiexec.exe"
$SetupArguments = "/i `"$ScriptDir\MicrosoftEdgeEnterpriseX64.msi`" /q /l $MSILogFile"

# Delete log files if exist
If (Test-Path $LogFile){Remove-Item -Path $LogFile -Force }
If (Test-Path $MSILogFile){Remove-Item -Path $MSILogFile -Force }

# Start logging
"$(TimeStamp) Starting install of $SetupName" | Out-File -Append $LogFile
"$(TimeStamp) About to run the following command line: $SetupFile $SetupArguments" | Out-File -Append $LogFile

# Start Installation
$Result = Start-Process -FilePath $SetupFile -ArgumentList $SetupArguments -Wait -Passthru

# Check the result
If($Result.Exitcode -ne 0)
     # Not good, setup failed
     "$(TimeStamp) ERROR: Setup failed with exit code $($Result.Exitcode), review $MSILogFile and msedge_installer.log for more details" | Out-File -Append $LogFile
     "$(TimeStamp) NOTE: If the MSI log shows `"Error 1722. There is a problem with this Windows Installer package.`" it's most commonly because Windows 10 was not updated with the latest CU" | Out-File -Append $LogFile
    "$(TimeStamp) All good, setup compleeted with exit code $($Result.Exitcode)" | Out-File -Append $LogFile 

# Modify master_preferences file with some basic settings
# Note: Group Policy settings will win over master preferences
$MasterPreferencesFile = "C:\Program Files (x86)\Microsoft\Edge\Application\master_preferences"
If(Test-path $MasterPreferencesFile){
    "$(TimeStamp) Master Preference file found, modifying it" | Out-File -Append $LogFile
    $MPJSON = Get-Content -Raw -Path $MasterPreferencesFile | ConvertFrom-Json
    $MPJSON.distribution | Add-Member -Name "skip_first_run_ui" -Value $true -MemberType NoteProperty -Force
    $MPJSON.distribution | Add-Member -Name "show_welcome_page" -Value $false -MemberType NoteProperty
    $MPJSON.distribution | Add-Member -Name "import_search_engine" -Value $false -MemberType NoteProperty
    $MPJSON.distribution | Add-Member -Name "import_history" -Value $false -MemberType NoteProperty
    $MPJSON.distribution | Add-Member -Name "suppress_first_run_bubble" -Value $true -MemberType NoteProperty
    $MPJSON.distribution | Add-Member -Name "suppress_first_run_default_browser_prompt" -Value $true -MemberType NoteProperty
    $MPJSON | ConvertTo-Json -Compress | Out-File $MasterPreferencesFile -Encoding utf8

# Remove Desktop Shortcut
Remove-Item -Path "$Env:PUBLIC\Desktop\Microsoft Edge.lnk"

About the author

Johan Arwidmark

5 1 vote
Article Rating
Notify of
Oldest Most Voted
Inline Feedbacks
View all comments
5 months ago

Do you have a standard PowerShell wrapper that you use for MSI packages? Normally it's pretty straight forward to just call msiexec directly, but when you add in patches that require absolute paths it starts to get messy quick.

Last edited 5 months ago by Brian
John Van Hausen
John Van Hausen
7 months ago

have you gotten anywhere Johan? I've written a similar script to edit master prefs. Same thing as you mention, it seem to be ignored,