M365 – Azure AD Inactive Users (PowerShell)

Below is a ready-to-use script. Review and adapt variables to your environment.

Connect-MgGraph -Scopes 'AuditLog.Read.All','User.Read.All' -NoWelcome
$since = (Get-Date).AddDays(-90)
Get-MgAuditLogSignIn -Filter "createdDateTime ge $($since.ToString('o'))" -All |
  Group-Object userId | Where-Object {$_.Count -eq 0} | Select -ExpandProperty Name
  

← Back to SQL