Azure AD : Need powershell script to fetch Azure AD User Sign-in date and time (Last logon)

Sheshank Dhoot 1 Reputation point
2021-09-16T16:54:07.817+00:00

On Premise AD does not update the Azure AD Sign-in Logs and O365 User Activity report does not include the interactive sign in performed by users.
Need PowerShell script to fetch each Azure AD user Sign-in logs, trying to reconcile the On-premise users last login data with Azure AD Sign-in activity to find inactive users.

Get-MSolUser and Get-AzureAdUser does not include the required data and the details are required for unlicensed users also.

Assuming Inactive users to be the one who have not signed-in in last 90 days.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
Microsoft Entra
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,569 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 96,926 Reputation points MVP
    2021-09-16T19:14:11.747+00:00

  2. Limitless Technology 39,371 Reputation points
    2021-09-17T14:22:43.503+00:00

    Hello,

    Thank you for reaching out.

    Additionaly,

    You can use Get-AzureADAuditSignInLogs powershell command to get user sign in logs from Azure AD.

    https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureadauditsigninlogs?view=azureadps-2.0-preview

    Hope this helps,


  3. Krystle Wright 1 Reputation point
    2022-11-18T13:50:01.347+00:00

    Did anyone find the answer? I am also needing the answer for SheshankDhoot-2954 question.

    0 comments No comments