Microsoft Security Tech Accelerator
Dec 06 2023, 07:00 AM - 12:00 PM (PST)
Microsoft Tech Community

I need to export Guest users' "Last Login Date/Time".

Copper Contributor

Could anyone point me in the right direction to export a CSV of last login date/time for Guest users on Entra/Azure AD?

 

I can see the data in Entra by adding the 'Last Login Time' column but when exported, this column isn't included.

3 Replies
You can do something like this:

Get-MgUser -Filter "userType eq 'Guest'" -All -Property Id,userPrincipalName,signInActivity | select Id,UserPrincipalName,@{n="LastLogin";e={$_.SignInActivity.lastSignInDateTime}}

This leverages the Graph SDK for PowerShell. If you need additional properties, make sure to add them both under the -Property list and under the select statement.
Thanks for this. How do I carry out the above?