Last active
February 26, 2022 08:10
-
-
Save alexmags/1eb9b1ca220975b87162e1c4fcd32726 to your computer and use it in GitHub Desktop.
Report in AAD sign in logs the last time an Azure AD guest account was used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://blog.alexmags.com/tags/kql/ | |
let last_sign_in_by_account = | |
SigninLogs | |
| where TimeGenerated > now(-90d) | |
| where ResultType == 0 | |
// filtering out local accounts to identify guest accounts. I couldn't identify account type in log data. Maybe TimeGenerated.HomeTenantId?? | |
| where UserPrincipalName !endswith "companyname.com" and UserPrincipalName !endswith "AlsoCompanyname.com" and UserPrincipalName !endswith "tenantname.onmicrosoft.com" and UserPrincipalName !endswith "YetAnotherVerifiedDomain.com" and UserPrincipalName !endswith "SeriouslyICouldntIdentifyAccountTypeInLogData.com" | |
// get last login per account | |
| summarize argmax(TimeGenerated, *) by UserPrincipalName; | |
last_sign_in_by_account | |
| project max_TimeGenerated, domain=split(UserPrincipalName,'@')[1], UserPrincipalName, max_TimeGenerated_AppDisplayName, max_TimeGenerated_AuthenticationRequirement, max_TimeGenerated_ClientAppUsed, max_TimeGenerated_UserDisplayName | |
| order by max_TimeGenerated desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment