Write-Host "=== CHROME NOTIFICATION LOCKDOWN SCRIPT ===" -ForegroundColor Cyan # 1. Enforce Chrome Enterprise Registry Policy (Blocks future prompt requests globally) Write-Host "[+] Configuring Registry Policies to block notifications..." -ForegroundColor Windows $RegistryPaths = @( "HKLM:\SOFTWARE\Policies\Google\Chrome", "HKCU:\SOFTWARE\Policies\Google\Chrome" ) foreach ($RegPath in $RegistryPaths) { if (-not (Test-Path $RegPath)) { New-Item -Path $RegPath -Force | Out-Null } # Value 2 = "Do not allow any site to show desktop notifications" New-ItemProperty -Path $RegPath -Name "DefaultNotificationsSetting" -Value 2 -PropertyType DWord -Force | Out-Null } Write-Host " -> Registry policy applied: Notifications set to 'Block globally'." -ForegroundColor Green # 2. Close running Chrome processes to safely edit local configuration databases Write-Host "`n[+] Terminating running Google Chrome instances to apply changes..." -ForegroundColor Windows $ChromeProcesses = Get-Process -Name "chrome" -ErrorAction SilentlyContinue if ($ChromeProcesses) { Stop-Process -Name "chrome" -Force Start-Sleep -Seconds 2 Write-Host " -> Chrome processes closed." -ForegroundColor Yellow } # 3. Locate and purge existing notification permissions in User Profiles Write-Host "`n[+] Scanning and cleaning local Chrome profile preferences..." -ForegroundColor Windows $UserProfilesDir = "C:\Users" $Users = Get-ChildItem -Path $UserProfilesDir -Directory foreach ($User in $Users) { $ChromeDataPath = "$UserProfilesDir\$($User.Name)\AppData\Local\Google\Chrome\User Data" if (Test-Path $ChromeDataPath) { Write-Host " -> Found Chrome Data for user: $($User.Name)" -ForegroundColor Cyan # Target default profile and any additional sub-profiles (Profile 1, Profile 2, etc.) $Profiles = Get-ChildItem -Path $ChromeDataPath -Directory | Where-Object { $_.Name -eq "Default" -or $_.Name -like "Profile*" } foreach ($Profile in $Profiles) { $PrefFile = "$($Profile.FullName)\Preferences" if (Test-Path $PrefFile) { try { # Read the Preferences JSON file $PrefJson = Get-Content -Raw -Path $PrefFile | ConvertFrom-Json # Target and wipe out the notifications permissions block if it exists if ($PrefJson.profile -and $PrefJson.profile.content_settings -and $PrefJson.profile.content_settings.exceptions) { if ($PrefJson.profile.content_settings.exceptions.notifications) { # Clear the notification exceptions object completely $PrefJson.profile.content_settings.exceptions.notifications = New-Object PSObject # Save the modified JSON back to disk cleanly $PrefJson | ConvertTo-Json -Depth 100 | Set-Content -Path $PrefFile -Force Write-Host " [✓] Reset notification exceptions in profile: $($Profile.Name)" -ForegroundColor Green } } } catch { Write-Host " [!] Error modifying file for $($User.Name) ($($Profile.Name)): $_" -ForegroundColor Red } } } } } Write-Host "`n=== RECONFIG COMPLETE ===" -ForegroundColor Cyan Write-Host "Chrome notifications have been cleared out and hard-blocked via registry policies." -ForegroundColor Green