Archived
52 lines
2.5 KiB
Plaintext
52 lines
2.5 KiB
Plaintext
# 1. Stop the service first to release any file locks
|
|
Stop-Service -Name "lfsvc" -Force -ErrorAction SilentlyContinue
|
|
|
|
# 2. Configure lfsvc registry startup type directly (2 = Automatic)
|
|
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc" -Name "Start" -Value 2 -Type DWord -Force
|
|
|
|
# 3. Ensure the service host parameters are properly mapped
|
|
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. Remove all Group Policy & MDM location restrictions
|
|
$policyPaths = @(
|
|
"HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors",
|
|
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors",
|
|
"HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy",
|
|
"HKCU:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy"
|
|
)
|
|
|
|
foreach ($path in $policyPaths) {
|
|
if (Test-Path $path) {
|
|
Remove-ItemProperty -Path $path -Name "DisableLocation" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path $path -Name "DisableLocationScripting" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path $path -Name "DisableSensors" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path $path -Name "LetAppsAccessLocation" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path $path -Name "LetAppsAccessLocation_UserInControlOfTheseApps" -ErrorAction SilentlyContinue
|
|
Remove-ItemProperty -Path $path -Name "LetAppsAccessLocation_ForceAllowTheseApps" -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
# 5. Reset master capability consent keys
|
|
$consentPaths = @(
|
|
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location",
|
|
"HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location"
|
|
)
|
|
|
|
foreach ($path in $consentPaths) {
|
|
if (-not (Test-Path $path)) {
|
|
New-Item -Path $path -Force | Out-Null
|
|
}
|
|
Set-ItemProperty -Path $path -Name "Value" -Value "Allow" -Type String -Force
|
|
}
|
|
|
|
# 6. Enable Windows Sensor platform permissions
|
|
$sensorGuid = "{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
|
|
$sensorPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Permissions\$sensorGuid"
|
|
if (-not (Test-Path $sensorPath)) {
|
|
New-Item -Path $sensorPath -Force | Out-Null
|
|
}
|
|
Set-ItemProperty -Path $sensorPath -Name "SensorPermissionState" -Value 1 -Type DWord -Force
|
|
|
|
# 7. Start the service
|
|
Start-Service -Name "lfsvc" |