How can i get inactive azure ad users more than 90 days?
$date = (get-date).AddDays(-90)
get-azureaduser -All $true -Filter {(LastLogonDate -lt $date) -and (accountEnabled eq true)}
CodePudding user response:
DO you have access to graph? This will get you the results you want
https://graph.microsoft.com/beta/users?$filter=signInActivity/lastSignInDateTime le 2022-05-01T00:00:00Z&$filter=accountEnabled eq true&$select=displayName,signInActivity
Just make sure your account has the following permissions AuditLog.Read.All Directory.Read.All
All you'd need to adjust is the date that you want to filter signInActivity by.