Forum Discussion
JakobRohde
Sep 22, 2017Iron Contributor
List all users' last login date
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 ne...
Malith_Jayashan
Oct 18, 2022Copper Contributor
This can be done using AzureADPreview
Import-Module AzureADPreview
$UsersUPN = (Get-AzureADUser -Top 20000).UserPrincipalName
foreach($user in $UsersUPN)
{
Get-AzureADAuditSignInLogs -Filter "UserPrincipalName eq '$user'" -Top 1| `
select CreatedDateTime, UserPrincipalName, IsInteractive, AppDisplayName, IpAddress, TokenIssuerType, @{Name = 'DeviceOS'; Expression = {$_.DeviceDetail.OperatingSystem}}
Start-Sleep -Seconds 5
}
A Start-Sleep -Seconds 5 delay should be added in order to bypass the "Too many requests" error code