List all users' last login date

Iron Contributor

Is it possible, using PowerShell, to list all AAD users' last login date (no matter how they logged in)? I have found a couple of scripts that check the last mailbox login, but that is not what we need, because we also want to list unlicensed users.

70 Replies
Hi @mdiloreto,
I'm fine thanks and hope the same for you.
Sorry for the late answer.
Yes, that is correct. An empty value or inconsistent mean that the user has never been signed-up against Azure AD.

Best Regard
While this is good information for AAD, it appears to be limited to the past 90 days. We are looking for something static and retrievable like LastLogonTimestamp in AD or LastLogonTime in Exchange Online MailboxStatistics.

@Donald Mosteller 

 

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

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.

 

The thread that keeps on keeping on....

Here is a new page from MS on the topic with all the required information.

https://learn.microsoft.com/en-us/azure/active-directory/reports-monitoring/howto-manage-inactive-us...

Hi Jakob,

Sorry, is possible to use one command in PowerShell for extraction the last logon in software Microsoft Project?

Thank you
Yes empty mean never logged-in.
i ran the script but it's giving me empty results on the LastSignInDate, do you know why this is happening?

@Staniko 

 

i tried this script and it works very well thanks. But I have a problem the results stop after about 100 users. 

Hey @everyone,
Because of the paging size change from 1000 to 120, guests maybe be reported incorrectly and deleted. If you are using this script please grab an updated copy and report any bugs!

https://github.com/JBines/Remove-StaleGuests
https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/1898

@Kevin Morgan 

 

Is it possible to to get a last activity date for only guest users? I have about 25k that I need to cleanup and need to determine if they have logged on in the past 90days or more.

 

thanks

Kevin

@Robert Luck At first glance, AdminDroid is the answer to my lastlogin prayers!  Just starting to play with it now.  Thanks!