forked from CyberDrain/Check
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-Windows-Chrome-and-Edge.ps1
More file actions
49 lines (43 loc) · 2.27 KB
/
Remove-Windows-Chrome-and-Edge.ps1
File metadata and controls
49 lines (43 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Define extension details (same as install-check.ps1)
# Chrome
$chromeExtensionId = "benimdeioplgkhanklclahllklceahbe"
$chromeManagedStorageKey = "HKLM:\SOFTWARE\Policies\Google\Chrome\3rdparty\extensions\$chromeExtensionId\policy"
$chromeExtensionSettingsKey = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionSettings\$chromeExtensionId"
# Edge
$edgeExtensionId = "knepjpocdagponkonnbggpcnhnaikajg"
$edgeManagedStorageKey = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\3rdparty\extensions\$edgeExtensionId\policy"
$edgeExtensionSettingsKey = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\ExtensionSettings\$edgeExtensionId"
# Function to remove extension settings
function Remove-ExtensionSettings {
param (
[string]$ExtensionId,
[string]$ManagedStorageKey,
[string]$ExtensionSettingsKey
)
# Remove all managed policy values and nested keys created for this extension.
if (Test-Path $ManagedStorageKey) {
try {
Remove-Item -Path $ManagedStorageKey -Recurse -Force -ErrorAction Stop
Write-Host "Removed managed storage key: $ManagedStorageKey"
} catch {
Write-Warning "Failed to remove managed storage key: $ManagedStorageKey. Error: $($_.Exception.Message)"
}
} else {
Write-Host "Managed storage key not found (already removed): $ManagedStorageKey"
}
# Remove extension install/settings key for this extension.
if (Test-Path $ExtensionSettingsKey) {
try {
Remove-Item -Path $ExtensionSettingsKey -Recurse -Force -ErrorAction Stop
Write-Host "Removed extension settings key: $ExtensionSettingsKey"
} catch {
Write-Warning "Failed to remove extension settings key: $ExtensionSettingsKey. Error: $($_.Exception.Message)"
}
} else {
Write-Host "Extension settings key not found (already removed): $ExtensionSettingsKey"
}
Write-Host "Completed removal of extension settings for $ExtensionId"
}
# Remove settings for Chrome and Edge
Remove-ExtensionSettings -ExtensionId $chromeExtensionId -ManagedStorageKey $chromeManagedStorageKey -ExtensionSettingsKey $chromeExtensionSettingsKey
Remove-ExtensionSettings -ExtensionId $edgeExtensionId -ManagedStorageKey $edgeManagedStorageKey -ExtensionSettingsKey $edgeExtensionSettingsKey