Remove and Block Edge Extensions via Powershell

Written by

in

As an IT Professional :tm: I am the defacto Director of IT for my family and friends. I enjoy this (unpaid) role because I try to help my “users” learn more about tech and how it can improve their every day life. Microsoft Edge, or, IE The Next Generation as I like to call it is powered by Chromium. Chrome and Edge share that in common, part of the Chromium engine allows for extensions. Google has a robust approval process thru the Chrome Extension store. Microsoft, eh, not so much.

It’s really easy for threat actors to fool a normal user into instaling an Edge Extension. Some of these mask themselves common applications and threaten the user that they are at risk. Which is true, but the malformed Edge Extenstion is the threat.

If users have a need / want for extensions they should just use Chrome. But, if they get one of these bad Edge extension, I created a pair of powershell scripts to remove any Edge extension and block installation of future Edge extensions.

Uninstall Edge Extensions:

# Close Edge first — files are locked while it runs
Get-Process msedge -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 3

$userData = "$env:LOCALAPPDATA\Microsoft\Edge\User Data"

Get-ChildItem -Path $userData -Directory -ErrorAction SilentlyContinue |
    Where-Object { $_.Name -eq "Default" -or $_.Name -like "Profile *" } |
    ForEach-Object {
        $extPath = Join-Path $_.FullName "Extensions"
        if (Test-Path $extPath) {
            Write-Host "Clearing extensions in $($_.Name)"
            Remove-Item -Path "$extPath\*" -Recurse -Force -ErrorAction SilentlyContinue
        }
    }

Block any Edge Extension install in the future:

$key = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallBlocklist"
New-Item -Path $key -Force | Out-Null
Set-ItemProperty -Path $key -Name "1" -Value "*"
gpupdate /force

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *