Forum Discussion
List all users' last login date
The Microsoft Graph API now supports the resource property signInActivity in users end-point, this resource exposes the lastSignInDateTime property which shows the last time a user made a successful sign-in. Fetching signInActivity property requires an Azure AD Premium P1/P2 license and the AuditLog.Read.All permission. The following request retrieves user details along with signInActivity property.
#GET Request
https://graph.microsoft.com/beta/users?$select=displayName,signInActivity
Before Microsoft Graph supports this property, we need to either get the mailbox last logon time using the Get-MailboxStatistics cmdlet or we need to crawl the Azure AD sign-in logs or the Unified audit logs in the Security and Compliance Center.
You can refer the below post to know more details about how to find and export Last login date for all Azure AD Users using PowerShell.
- https://morgantechspace.com/2021/09/find-last-login-date-for-all-azure-ad-users-using-powershell.html
- Joshua BinesMar 30, 2022Iron Contributor
Kevin_Morgan license? 😉 the lastsignin property is a static value that is populated for all user accounts including guest accounts (see thread) back to apr 2020.
Edit: I'm guessing you mean the tenant has 'any' aad p1/p2. Haven't tested this maybe you are right?
- Kevin_MorganMar 31, 2022Iron Contributor
Yes the value may get populated for all users. But we need the license to retrieve the lastlogin value through Microsoft Graph API. The https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-beta&tabs=http#example-3-get-users-including-their-last-sign-in-time itself still indicates the same and so my testing. Hope still there is no other API or PowerShell cmdlet to get the details without Azure AD Premium P1/P2 license. Can you please point me if you know any resources?
- Joshua BinesMar 31, 2022Iron ContributorYep quite right... looks like it's a premium feature for the tenant (not the user object) I haven't run into any such issues myself but good to note thanks!