top of page
Writer's pictureJagjeet Singh

Script to Remove "Momentum" Google Chrome Extension


This script is written in PowerShell and is designed to remove a specific Google Chrome extension called "Momentum" from the system.


# By Jagjeet on 05/16/2023
# Remove "Momentum" Google chrome extension.
# https://chrome.google.com/webstore/detail/momentum/laookkfknpbbblfpciffpaejjkokdgca


$regKeyPath = 'HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist'
$targetValue = 'laookkfknpbbblfpciffpaejjkokdgca'

if (Test-Path $regKeyPath) {
    $regKey = Get-Item -Path $regKeyPath
   
    $values = $regKey.GetValueNames()

    if ($values) {
        foreach ($valueName in $values) {
            $value = $regKey.GetValue($valueName)

            if ($value -like "*$targetValue*") {
                #$regKey.DeleteValue($valueName)
                 Write-Host $regKey
               Remove-ItemProperty -Path $regKeyPath -Name $valueName
                Write-Host "Value removed: $valueName"
            }
        }
    } else {
        Write-Host "No values found in the registry key."
    }
} else {
    Write-Host "Registry key not found."
}

The script performs the following steps:

  1. It sets the value of the variable $regKeyPath to the registry path where the Google Chrome extension configuration is stored. In this case, it is set to 'HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist'.

  2. It sets the value of the variable $targetValue to the ID of the extension that needs to be removed. In this case, the ID is 'laookkfknpbbblfpciffpaejjkokdgca'.

  3. It checks if the specified registry path exists using the Test-Path cmdlet. If the path exists, it proceeds with the removal process. Otherwise, it displays the message "Registry key not found."

  4. If the registry path exists, the script retrieves the registry key using the Get-Item cmdlet and assigns it to the variable $regKey.

  5. It retrieves all the value names present in the registry key using the GetValueNames method and stores them in the variable $values.

  6. If there are values present in the registry key, the script iterates through each value name using a foreach loop.

  7. For each value name, it retrieves the corresponding value using the GetValue method and assigns it to the variable $value.

  8. It checks if the retrieved value contains the target extension ID by using the -like operator and the wildcard pattern * around the target value. If the value contains the target extension ID, it proceeds with the removal process.

  9. The script removes the value from the registry key using the Remove-ItemProperty cmdlet with the specified registry path and value name.

  10. It displays a message indicating that the value has been removed, including the name of the removed value.

  11. If there are no values found in the registry key, it displays the message "No values found in the registry key."

Overall, this script checks for the presence of the "Momentum" Google Chrome extension in the system's registry and removes it if found.



17 views0 comments

Recent Posts

See All

Comments


bottom of page