Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API

In this article, I will explain how to set up or configure the Time Zone for Windows machines using Intune. There are several ways to configure the Time Zone on Windows machines; however, I will describe the easiest and most automated method to establish the Intune policy.

Microsoft Intune provides a wide range of policies within the admin center. These policies can apply predefined settings to users and devices, all of which can be automated using Graph APIs. I will create a configuration policy that will Configure Time Zone and deploy it to security groups in this example.

For example, if your organization or client operates across multiple country, you could group the devices into different Entra security groups for each country and deploy the settings catalog policy in Intune that would Configure Time Zone for each region.

I will use the Microsoft Graph API to Configure Time Zone for Windows 11 Machines in this example. You may need to just change the OMA-URI value when you create new policies for different regions. I am sure, it will save your time and efforts.

Patch My PC

Discuss More About Microsoft Graph API

Microsoft Graph, a RESTful web API, facilitates access to Microsoft Cloud service resources. It lets you access data, intelligence, and insights from Microsoft 365 and other Microsoft Cloud services through a single endpoint, including data from Microsoft 365, Windows, and Enterprise Mobility + Security.

This Microsoft Graph API is designed to perform the same range of Intune operations as those available through the Azure Portal. By using Microsoft Graph, developers can build intelligent applications that leverage the power of Microsoft 365 and other Microsoft services to enhance productivity and collaboration.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API 1
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.01

Microsoft Graph can be leveraged to create personalized experiences catering to individual users’ unique contexts, thereby increasing their productivity. It offers a robust suite of services for managing user and device identity, access, compliance, security, and data access on the following Microsoft cloud services.

You should have enough permission to run the query. Microsoft has documented an overview of Microsoft Graph permissions. Kindly refer to it to gain a better understanding of Graph permissions. Request the least privileged permissions that your app needs in order to access data and function correctly. Requesting permissions with more than the necessary privileges is a poor security practice.

List all the Time zones

Well, before automating the configuration of time zones for Windows 11 machines using Intune through the Microsoft Graph API, let’s gather all the available time zones. The code below lists the time zones and exports the details into a .CSV file.  

Get-TimeZone -ListAvailable | Select-Object Id,DisplayName,StandardName | Export-Csv C:\temp\timeZone.csv -NoClobber -NoTypeInformation -Append

This file should have the list of available time zones. The time zones Id value is mandatory input when you execute the API call. The Id has to be set in JSON Input.

Create Intune Policy to Configure Time Zone through Graph API

I will use Graph Explorer, a handy browser-based tool for running your Graph calls to automate the task. The API call can be made using the graph explorer. Also, you could use PowerShell to call the API calls

NOTE! You may need to log in to Graph Explorer using your credentials if it's your first time. 
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.02
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.02

You should use the POST request method for the endpoint since you are Sending Data to APIs. The below table explains you the HTTP methods in details.

HTTP MethodsDescription
GETGET method is to retrieve data from the server simply
POSTThe POST HTTP request method sends data to the server for processing.
PUTThe PUT method completely replaces a resource identified with a given URL.
DELETEThe DELETE method removes or deletes a resource from a server.
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Table.01

The below endpoint should be used to Create Intune Policy to Configure Time Zone through Graph API. You must have enough permission to run the above endpoint. I have created a table below with permission details.

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations
Permission DescriptionAdminConsentRequired
DeviceManagementConfiguration.ReadWrite.AllAllows the app to read and write properties of Microsoft Intune-managed device configuration and device compliance policies and their assignment to groups without a signed-in user.Yes
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Table.02

Change the request method from GET to POST and paste the below JSON input in the request body. You can change the displayName and description.

{
    "@odata.type": "#microsoft.graph.windows10CustomConfiguration",
    "displayName": "Configure Time Zone for Windows 11 Machines",
    "description": "Configure Time Zone for Windows 11 Machines - HTMD",
    "omaSettings": [
        {
            "@odata.type": "#microsoft.graph.omaSettingString",
            "displayName": "Configure Time Zone for Windows 11 Machines",
            "description": "Configure Time Zone for Windows 11 Machines - HTMD",
            "omaUri": "./Device/Vendor/MSFT/Policy/Config/TimeLanguageSettings/ConfigureTimeZone",
            "value": "India Standard Time"
        }
    ]
}

./Device/Vendor/MSFT/Policy/Config/TimeLanguageSettings/ConfigureTimeZone is the OMA-URI and the value is India Standard Time. You can change the value with any time zones Id.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.03
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.03

Once you click the Run query button, the graph explorer will return a response message. You will receive a success message with the text created-201.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API 2
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.04

Make a note of the ID if you would like to deploy this policy to any security group later. You could use the Graph API make the deployment.

Verify the Configuration Policy

As per the response message, the policy has been created successfully. Sign in to the Microsoft Intune Admin portal and verify the Configuration Policy.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.05
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.05

The policy that we created to Configure Time Zone for Windows 11 Machines is available in the Intune portal. However, its not assigned to any security group. Let’s learn how to assign the policy to a Security group

Assign a Configuration Policy to the Security Group using Graph API

You need the Security Group’s group ID to deploy the Intune Camera Settings using the Graph API. You must have noted down the policy ID already; however, let’s learn how to get the Security Group ID to deploy the policy.  

  • Sign in back to Graph Explorer with your admin account.
  • Replace the Graph URL with the following endpoint. It should be GET call

https://graph.microsoft.com/v1.0/groups?$filter=displayName eq 'HTMD - Test Computers'&$select=id,displayName

Within seconds of clicking Run query, you will receive a success message with the text OK- 200. Note down the id value for further use.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.06
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.06

Sign in back to Graph Explorer with your admin account. Replace the Graph URL with the following endpoint. Replace the {profile-id} with the actual profile ID.

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations/{profile-id}/assignments

You should use the POST request method here. Change the request method from GET to POST and paste the JSON code below into the request body and click on Run query. Make sure to replace the groupId with the id that you noted above.

{
    "@odata.type": "#microsoft.graph.deviceConfigurationAssignment",
    "target": {
        "@odata.type": "#microsoft.graph.groupAssignmentTarget",
        "groupId": "48bd6547-dc18-498e-8143-11c49a818836"
    }
}
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.07
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.07

Verify the Policy Assignment

The policy has been assigned to the Security Group. Sign in to the Microsoft Intune Admin portal to verify the policy assignment. Select the configuration profile you deployed to check the assignment status from properties.

Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.08
Configure Time Zone for Windows 11 Machines using Intune through Microsoft Graph API. Fig.08

I hope this article will be a valuable resource for you and your organization. Thank you for being so patient in reading this post. I look forward to seeing you in the next post. Keep supporting the HTMD Community.

Need Further Assistance or Have Technical Questions?

Join the LinkedIn Page and Telegram group to get the latest step-by-step guides and news updates. Join our Meetup Page to participate in User group meetings. Also, Join the WhatsApp Community to get the latest news on Microsoft Technologies. We are there on Reddit as well.

Author

About the Author: Sujin Nelladath, a Microsoft Graph MVP with over ten years of experience in SCCM device management and Automation solutions, writes and shares his experiences with Microsoft device management technologies, Azure, and PowerShell automation.

Leave a Comment