-
Notifications
You must be signed in to change notification settings - Fork 0
/
Disable-ChromeNotifications.ps1
54 lines (45 loc) · 1.58 KB
/
Disable-ChromeNotifications.ps1
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
50
51
52
53
54
# Disable Chrome Notifications in Windows 10/11
# Written by Jonathan Bullock
# 2023 - 10 - 21
# Define the path to the Chrome policies key in the registry
$registryPath = "HKCU:\Software\Policies\Google\Chrome"
$backupFolder = "C:\brockit"
$backupFile = "C:\brockit\ChromePolicyBackup.reg"
# confirm BrockIT folder exists
if (-not (Test-Path $backupFolder)) {
New-Item -Path $backupFolder -ItemType Directory
}
# Check if the Chrome policy registry path exists
if (Test-Path $registryPath) {
# Backup the registry key
Export-RegistryKey -Path $registryPath -Destination $backupFile
Write-Host "Backup of Chrome policies created at $backupFile"
} else {
Write-Host "Chrome policy registry key does not exist. No backup needed."
}
# Check if the path exists, if not, create it
if (-not (Test-Path $registryPath)) {
New-Item -Path $registryPath -Force
}
# Set the policy for disabling notifications
# 2 means to block all notifications
Set-ItemProperty -Path $registryPath -Name "DefaultNotificationsSetting" -Value 2
# Output the status
if (Get-ItemProperty -Path $registryPath -Name "DefaultNotificationsSetting") {
Write-Host "Chrome notifications have been successfully blocked."
} else {
Write-Host "Failed to block Chrome notifications."
}
# Function to export a registry key
function Export-RegistryKey {
param (
[string]$Path,
[string]$Destination
)
try {
Export-Registry -Path $Path -File $Destination
Write-Host "Registry key exported successfully."
} catch {
Write-Host "Error exporting registry key: $_"
}
}