# Script to silently configure Chrome and Edge extension removal policies
# --- Chrome Settings ---
$chromeBaseRegistryPath = "HKLM:\Software\Policies\Google\Chrome"
$chromeValueName = "ExtensionSettings"
$chromeJsonData = '{"moaklgcgokbgplldonjkoochhlefkbjf":{"installation_mode":"removed"}}'
# Silently create the Chrome registry path if it does not exist
if (-not (Test-Path $chromeBaseRegistryPath)) {
New-Item -Path $chromeBaseRegistryPath -Force | Out-Null
}
# Silently delete the Chrome ExtensionSettings key if it incorrectly exists as a folder
if (Test-Path "$chromeBaseRegistryPath\$chromeValueName" -PathType Container) {
Remove-Item -Path "$chromeBaseRegistryPath\$chromeValueName" -Recurse -Force | Out-Null
}
# Add or update the Chrome ExtensionSettings registry value
Set-ItemProperty -Path $chromeBaseRegistryPath -Name $chromeValueName -Value $chromeJsonData -Force | Out-Null
# --- Edge Settings ---
$edgeBaseRegistryPath = "HKLM:\Software\Policies\Microsoft\Edge"
$edgeValueName = "ExtensionSettings"
$edgeJsonData = '{"hjifncajikcdkhlofdjjlhcjoennmdfc":{"installation_mode":"removed"}}'
# Silently create the Edge registry path if it does not exist
if (-not (Test-Path $edgeBaseRegistryPath)) {
New-Item -Path $edgeBaseRegistryPath -Force | Out-Null
}
# Silently delete the Edge ExtensionSettings key if it incorrectly exists as a folder
if (Test-Path "$edgeBaseRegistryPath\$edgeValueName" -PathType Container) {
Remove-Item -Path "$edgeBaseRegistryPath\$edgeValueName" -Recurse -Force | Out-Null
}
# Add or update the Edge ExtensionSettings registry value
Set-ItemProperty -Path $edgeBaseRegistryPath -Name $edgeValueName -Value $edgeJsonData -Force | Out-Null