Remove Extension using Powershell script

How to Remove Chrome Extension Using PowerShell Script?

Google Chrome extensions are small software programs that are used to customize the browser for a better experience. It helps users to tailor Chrome functionality and behavior to individual needs or preferences. Google Chrome extensions are built using HTML, CSS, and JavaScript. Mostly Extensions are created to fulfill a single purpose, and it must have a minimal user interface. Chrome extensions can be downloaded and installed from the Chrome Web Store, but recently google increased its restrictions for installing third-party Chrome extensions to protect users from malicious code. So if you want to download and install any extension you have to download it from the Chrome web store.

Also, Google Chrome allows you to manage these installed extensions using the Chrome Extension manager. You can Open Chrome Extension manager using chrome://extensions/ URL. Extension Manager allows you to enable or Disable Extensions, you can see details of any installed extensions, and finally, you can Remove extensions. Removing Extensions is an easy task, you can simply navigate to the extensions page and then choose the extensions which you want to remove, and then select Remove. But what if you want to remove the extension for multiple computers, or if want to remove the extension for multiple users via Intune policy, then this article will guide you to Remove Chrome Extension Using PowerShell Script.

Remove Chrome Extension Using PowerShell script:

The following script will remove the Extension Registry and the app data, this script is tested with Intune portal.

$KeyPath = "HKLM:\Software\Policies\Google\Chrome"
$KeyName = "ExtensionSettings"
$KeyValue = '{"mekeapalnmjamikkojcedcdelbjeffnf":{"installation_mode":"removed"}}'
$chromePath = "C:\Program Files\Google\Chrome\Application"
$successCode = 0

try {
    # Update registry key 
    Set-ItemProperty -Path $KeyPath -Name $KeyName -Value $KeyValue -Force
}
catch {
    Write-Output "FAILED to update the registry key"
    exit 1
}

# Remove the extension directory
try {
    Remove-Item -Path "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Extensions\$($extensionId)" -Recurse -Force
}
catch {
    Write-Output "FAILED to remove the extension directory"
    exit 1
}

try {
    # Kill Chrome exe
    taskkill /F /IM "chrome.exe"
}
catch {
    Write-Output "FAILED to kill chrome"
    exit 1
}

try {
    # Start Chrome exe
    Start-Sleep -Milliseconds 1000
    Start-Process chrome.exe
    Start-Sleep -Milliseconds 10000
}
catch {
    Write-Output "FAILED to start chrome"
    exit 1
}

# remove the extension settings from the registry path
try {
    #Delete registry path
    Remove-ItemProperty -Path $KeyPath -Name $KeyName
}
catch {
    Write-Output "FAILED to remove the registry path"
    exit 1
}

exit $successCode

In this script, I have mentioned the Extension ID “mekeapalnmjamikkojcedcdelbjeffnf” for some random Chrome extensions, make sure you have replaced it with the correct extension ID which you want to remove.

To find the Chrome Extension ID just use the following steps:

  • open the Chrome extension page from the setting or from the below URL.

chrome://extensions/

  • From the Top right corner enable the Developer mode toggle button.
  • Now you can see the Extensions ID for all the extensions that you have installed.
Remove Chrome Extension Using PowerShell

Read Also:

How to Downgrade Google Chrome in Windows 11/10?

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top