MSEndpointMgr / Intune

Microsoft Intune scripts
MIT License
667 stars 247 forks source link

Autopilot/Set-WindowsTimeZone.ps1 is in a non-functional state #47

Open ghost opened 2 years ago

ghost commented 2 years ago

I have tried to run the Set-WindowsTimeZone script on several builds of Windows 10 and 11. The only change I made to the script is the key for AzureMaps.

Showcase:

Animation

The fix

During the Enable-LocationServices function, the following code is used to let Windows apps access location: https://github.com/MSEndpointMgr/Intune/blob/539205c1bf99aca6417f56afc47146d579c4d0d6/Autopilot/Set-WindowsTimeZone.ps1#L181-L182 If we take a look at the details of this policy setting, a DWord of 0 means the user is in control. We instead need to set it to 1.

image

With the value set to one, the script executes as expected:

Animation

However, by doing so, the location services are still force enabled after the script finished execution:

image

To get rid of this, I've edited the Disable-LocationServices function to include the LetAppsAccessLocation DWord and set it to 0:

$AppsAccessLocation = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy"
Set-RegistryValue -Path $AppsAccessLocation -Name "LetAppsAccessLocation" -Value 0 -Type "DWord"

image

After execution:

image