# 1. Terminate the Settings app process so it clears its cache Stop-Process -Name "SystemSettings" -Force -ErrorAction SilentlyContinue # 2. Set HKLM Device-wide consent New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Force | Out-Null Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Value "Allow" -Type String -Force # 3. Set the Geolocation service operational status flag to Active (1) New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Force | Out-Null Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Value 1 -Type DWord -Force # 4. Set HKCU User consent for all active user hives on the machine $userSids = Get-ChildItem "Registry::HKEY_USERS" | Where-Object { $_.PSChildName -match "^S-1-5-21-\d+-\d+-\d+-\d+$" } foreach ($sid in $userSids) { $targetPath = "Registry::HKEY_USERS\$($sid.PSChildName)\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" if (-not (Test-Path $targetPath)) { New-Item -Path $targetPath -Force | Out-Null } Set-ItemProperty -Path $targetPath -Name "Value" -Value "Allow" -Type String -Force } # 5. Restart the Geolocation service cleanly to reload registry state Restart-Service -Name "lfsvc" -Force # 6. Re-open the Location Settings page Start-Process "ms-settings:privacy-location"