Creating a Pretty Good Installer Script for Microsoft Edge

Here is a work in progress sample for a better installer script for Microsoft Edge. Any comments/feedback/ideas are more than welcome 🙂

Since the initial release I've removed the master_preferences section since its not support by Microsoft Edge (only for Google Chrome).

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
try{
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $LogFile = "$($tsenv.Value("LogPath"))\Install-MicrosoftEdge.log"
    $MSILogFile = "$($tsenv.Value("LogPath"))\Install-MicrosoftEdgeMS"

}
catch{
    # 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
}
Else{
    "$(TimeStamp) All good, setup compleeted with exit code $($Result.Exitcode)" | Out-File -Append $LogFile 
}

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

About the author

Johan Arwidmark

5 1 vote
Article Rating
Subscribe
Notify of
guest
6 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Michal Zobec
29 days ago

hello, I found in documentation following:

Are master preferences supported?No, master preferences are not supported.

https://docs.microsoft.com/en-us/deployedge/faqs-edge-in-the-enterprise#are-master-preferences-supported

Brian
Brian
8 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 8 months ago by Brian
John Van Hausen
John Van Hausen
10 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, 


>