Search code examples
azureazure-active-directoryintune

How to find last logged in user on Intune/Azure


I am currently working on a project where I am needing to find the active username (not the device name or hostname) of associates on the machines. Since there was no standard naming convention when the devices were provisioned, I am looking to find a way to figure out or see the last logged in users through Azure AD or Intune.

Not sure if I am making this post in the correct place, if not please be kind and suggest where I should post this.

Thanks!


Solution

  • To fetch the details of last logged on users on Intune, make use of below query in Microsoft Graph Explorer:

    GET https://graph.microsoft.com/beta/deviceManagement/managedDevices/{managedDeviceId}
    

    The above query will only work on beta version of Microsoft Graph.

    Please check the required permissions below:

    enter image description here

    In the output response, you can find the UserId and LastlogonDateTime in usersLoggedOn field.

    In order to display the username via UserId, make use of powershell script mentioned in this reference.

    Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant. Beta version is subject to change don't use it for production.

    For more information, please refer below links:

    Get windowsManagedDevice - Microsoft Graph beta | Microsoft Docs

    Find out last logon user of MDM assigned Coporate Device - Microsoft Q&A