PowerShell – Uninstall Microsoft Edge Browser

email me

Yeah, Microsoft. Just because I can.

Caveat: I uninstall WebView2 as well. Microsoft has been sneaking in more apps that require WebView2.

For example, the Teams MSIX won’t install without it. So, if you have apps that require WebView2, make sure you comment that section out, or reinstall it: Download WebView2

 

Code.ps1

Tested in the SYSTEM account.

# MrNetTek 
# eddiejackson.net 
# 7/29/2024
# free for public use 
# free to claim as your own

$ErrorActionPreference = 'SilentlyContinue'

# C:\Windows\Temp\msedge_installer.log

Clear-Host

# Kill Processes
Stop-Process -Name msiexec -Force -ErrorAction SilentlyContinue
Stop-Process -Name msedge -Force -ErrorAction SilentlyContinue
Stop-Process -Name msedgewebview2 -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdate -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdge_X64_127.0.2651.74 -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdge_X64_126.0.2592.113 -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdge_X64_126.0.2592.68 -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdateSetup -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdateCore -Force -ErrorAction SilentlyContinue
Stop-Process -Name setup -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdateBroker -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdateComRegisterShell64 -Force -ErrorAction SilentlyContinue
Stop-Process -Name MicrosoftEdgeUpdateOnDemand -Force -ErrorAction SilentlyContinue


# Uninstall using MsiExec.exe
Write-Host "UNINSTALL - MSIEXEC APP GUIDS"
Write-Host "---------------------------------------"
$appGUIDs = @("{A7A396E7-4AEF-3614-B571-FFC5A32C1E74}", 
              "{874E0B21-FAB4-39E3-AB6A-7DB6907E911A}", 
              "{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}",
              "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}", 
              "{62301ECF-E43E-4630-BC1E-E1B00D905BD6}")

foreach ($appGUID in $appGUIDs) {
    Write-Host "$appGUID"
    Start-Process msiexec.exe -ArgumentList "/x $appGUID /qn" -Wait
    Start-Sleep 1
}


# Uninstall using Setup.exe
Write-Host "`n`nUNINSTALL - SETUP.EXE APP VERSIONS"
Write-Host "---------------------------------------"
$versions = @("126.0.2592.68", "126.0.2592.113", "127.0.2651.74")

foreach ($version in $versions) {
    Write-Host "$version"
    cmd /c "C:\Program Files (x86)\Microsoft\Edge\Application\$($version)\Installer\setup.exe" -uninstall -system-level -verbose-logging -force-uninstall
    cmd /c "C:\Program Files (x86)\Microsoft\EdgeWebView\Application\$($version)\Installer\setup.exe" -uninstall -msedgewebview -system-level -verbose-logging -force-uninstall
    cmd /c "C:\Program Files (x86)\Microsoft\EdgeCore\$($version)\Installer\setup.exe" -uninstall -msedgecore -system-level -verbose-logging -force-uninstall
    Start-Sleep 1
}


# Brute Force Removal
# Delete registry keys
Write-Host "`n`nDELETE - REGKEY GUIDS"
Write-Host "---------------------------------------"
$regUninstallKeys = @("{A7A396E7-4AEF-3614-B571-FFC5A32C1E74}", 
             	    "{39E595CF-8F95-3876-A10A-1370CF2503AD}", 
                    "{874E0B21-FAB4-39E3-AB6A-7DB6907E911A}",
                    "{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}",
            	    "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}",
                    "{62301ECF-E43E-4630-BC1E-E1B00D905BD6}",
          	        "Microsoft EdgeWebView")

foreach ($regUninstallKey in $regUninstallKeys) {
    Write-Host "$regUninstallKey"
    Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$($regKey)" -Force
    Start-Sleep 1
}



# Make sure you delete any relative products from HKCR - weird things happen otherwise
Write-Host "`n`nDELETE - REGKEY PRODUCTS GUIDS"
Write-Host "---------------------------------------"
$productIDs = @("12B0E4784BAF3E93BAA6D76B09E719A1")

foreach ($productID in $productIDs) {
    Write-Host "$productID"
    Remove-Item -Path "HKCR:\Installer\Products\$($productID)" -Recurse -Force
    reg delete "HKCR\Installer\Products\$($productID)" /f
    Start-Sleep 1
}




# Remove Directories
Write-Host "`n`nDELETE - DIRECTORIES"
Write-Host "---------------------------------------"
$dirNames = @("C:\Program Files (x86)\Microsoft\Edge",
              "C:\Program Files (x86)\Microsoft\EdgeCore",
              "C:\Program Files (x86)\Microsoft\EdgeWebView",
              "C:\Program Files (x86)\Microsoft\EdgeUpdate",
              "C:\ProgramData\Microsoft\EdgeUpdate")

foreach ($dirName in $dirNames) {
    Write-Host "Delete $dirName"
    Remove-Item -Path "$dirName" -Recurse -Force
    Start-Sleep 1
}


Write-Host "`n`nDone!"



# Do dynamic scanning for missed versions

$edgeAppPath = "C:\Program Files (x86)\Microsoft\Edge\Application"
$versions = Get-ChildItem -Path $edgeAppPath -Directory

foreach ($version in $versions) {
    $installerPath = Join-Path -Path $version.FullName -ChildPath "Installer\setup.exe"
    if (Test-Path -Path $installerPath) {
        Start-Process -FilePath $installerPath -ArgumentList '-uninstall -system-level -verbose-logging -force-uninstall'
        # Im not using wait, because the setup.exe will sometimes lock up in SYSTEM
        Start-Sleep 20
        Stop-Process -Name setup -Force -ErrorAction SilentlyContinue
    }
}

$edgeWebViewPath = "C:\Program Files (x86)\Microsoft\EdgeWebView\Application"
$versions = Get-ChildItem -Path $edgeWebViewPath -Directory

foreach ($version in $versions) {
    $installerPath = Join-Path -Path $version.FullName -ChildPath "Installer\setup.exe"
    if (Test-Path -Path $installerPath) {
        Start-Process -FilePath $installerPath -ArgumentList '-uninstall -msedgewebview -system-level -verbose-logging -force-uninstall'
        # Im not using wait, because the setup.exe will sometimes lock up in SYSTEM
        Start-Sleep 20
        Stop-Process -Name setup -Force -ErrorAction SilentlyContinue
    }
}


$edgeCorePath = "C:\Program Files (x86)\Microsoft\EdgeCore"
$versions = Get-ChildItem -Path $edgeCorePath -Directory

foreach ($version in $versions) {
    $installerPath = Join-Path -Path $version.FullName -ChildPath "Installer\setup.exe"
    if (Test-Path -Path $installerPath) {
        Start-Process -FilePath $installerPath -ArgumentList '-uninstall -msedgecore -system-level -verbose-logging -force-uninstall'
        # Im not using wait, because the setup.exe will sometimes lock up in SYSTEM
        Start-Sleep 20
        Stop-Process -Name setup -Force -ErrorAction SilentlyContinue
    }
}


# Uninstalls via App Names
$path = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*'
$items = Get-ItemProperty -Path $path
foreach ($item in $items) {
    $sid = $item.PSChildName
    Get-AppxPackage -Name *edge* -User $sid | Remove-AppxPackage -Force
}

Get-AppxPackage -Name *edge* | Remove-AppxPackage -Force
Start-Sleep -Seconds 3

# Session Clean up
$appGUIDs = $empty
$items = $empty
$path = $empty
$sid = $empty
$versions = $empty
$regUninstallKeys = $empty
$dirNames = $empty
$productIDs = $empty

# Bye, Felicia