# Detect-ChromeLocalNetworkAccessAllowedForUrls.ps1 # Returns 0 when all required URLs exist in numeric REG_SZ values. # Returns 1 when missing or key not present. $RequiredUrls = @( "https://patchmypc-my.sharepoint.com" "https://patchmypc-my.sharepoint.com/" ) $RegPath = "HKLM:\SOFTWARE\Policies\Google\Chrome\LocalNetworkAccessAllowedForUrls" try { if (-not (Test-Path $RegPath)) { Write-Output "NonCompliant: key missing" exit 1 } $item = Get-ItemProperty -Path $RegPath -ErrorAction Stop $existingUrls = @() foreach ($p in $item.PSObject.Properties) { if ($p.Name -match '^\d+$') { $v = $p.Value -as [string] if ($null -ne $v -and $v.Trim().Length -gt 0) { $existingUrls += $v.Trim() } } } $missing = @() foreach ($u in $RequiredUrls) { if ($existingUrls -notcontains $u) { $missing += $u } } if ($missing.Count -gt 0) { Write-Output ("NonCompliant: missing " + ($missing -join ", ")) exit 1 } Write-Output "Compliant" exit 0 } catch { Write-Output ("NonCompliant: error " + $_.Exception.Message) exit 1 }