Use PowerShell for deployment
Automate location settings with PowerShell for efficient enterprise management or scripting.
- Open PowerShell as administrator:
- Right-click Start or press Win + X, then select Windows Terminal (Admin) or PowerShell (Admin).
- If Windows Terminal does not have PowerShell as the default command-line tool (check the tabs above the window), click the dropdown arrow in the tab area, then select PowerShell.
- Disable location services:
- Paste these commands:
New-Item -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors” -Force
New-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors” `
-Name “DisableLocation” -Value 1 -PropertyType DWord -ForceThe results should show that the location services option in Windows Settings is greyed out for all users.
- Paste these commands:
- Enable location services:
- Run this command:
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors” `
-Name “DisableLocation” -Value 0
- Run this command:
- Apply changes:
- Restart devices or force policy update with gpupdate /force.
💡Note: These PowerShell commands work identically in Windows 10 and 11.