How to get user's device info in MS Graph?

nabi04 56 Reputation points
2023-04-03T06:52:08.05+00:00

I am trying to determine what operating system a user is using upon login, whether Mac or Windows. Is there a query on getting it from MS Graph API?

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,823 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,776 questions
Microsoft Intune MacOs
Microsoft Intune MacOs
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.MacOs: A family of Apple operating systems for the Apple Mac line of computers.
69 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Unknown_Beast 145 Reputation points
    2023-04-03T07:20:09.9033333+00:00

    Yes, you can use the Microsoft Graph API to get the operating system of a user's device.

    To get the operating system of a user's device, you can use the "managedDevices" endpoint in Microsoft Graph API. Here are the steps you can follow:

    1. Authenticate: First, you need to authenticate with the Microsoft Graph API using a registered application and an authorized account. You can refer to the Microsoft Graph API documentation for more information on authentication.
    2. Get user's managed devices: Once authenticated, you can call the "managedDevices" endpoint to get a list of devices that are managed by your organization for a specific user. You can use the following endpoint:

    GET https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices

    Note: Replace {user-id} with the ID or userPrincipalName of the user you want to get managed devices for.

    1. Get operating system details: Once you have a list of managed devices, you can retrieve the operating system details for each device by calling the "registeredDevice" endpoint. You can use the following endpoint:

    GET https://graph.microsoft.com/v1.0/devices/{device-id}

    Note: Replace {device-id} with the ID of the device you want to get operating system details for.

    1. Parse operating system details: The "operatingSystem" property of the "registeredDevice" object contains the operating system details of the device. You can use this property to determine the operating system of the device. For example, the "operatingSystem" property might contain the value "Windows 10 Pro" or "MacOS Mojave".

    Note: If the user is not using a managed device, you may not be able to retrieve the operating system details.

    These are the general steps to get the operating system of a user's device using Microsoft Graph API. You can refer to the Microsoft Graph API documentation for more information on managing devices and retrieving operating system details.

    1 person found this answer helpful.