Getting All Azure AD User Last Sign-ins using the Microsoft Graph SDK for PowerShell.
This code compares both interactive and non-interactive sign-ins. The calculated ‘LastSignIn’ is the more recent of the two.
PowerShell Code
Note: This code requires the Microsoft Graph SDK for PowerShell.
Sample Output
UserPrincipalName CreatedDateTime LastSignIn LastSignInAsLocalTime
----------------- --------------- ---------- ---------------------
test1@somewhere.com 16/05/2023 10:17:53 AM 16/05/2023 10:27:02 AM 16/05/2023 6:27:02 PM
test2@somehwere.com 2/05/2023 5:41:23 AM 25/05/2023 2:09:50 PM 25/05/2023 10:09:50 PM
test3@somehwere.com 8/05/2023 2:41:24 AM 25/05/2023 2:09:50 PM 25/05/2023 10:09:50 PM
HTTP REST Example
An HTTP REST example without using the SDK.