Skip to content

Instantly share code, notes, and snippets.

@alexmags
Last active February 26, 2022 08:06
Show Gist options
  • Save alexmags/9226fdce69367319eaa7dd7afbac8fcb to your computer and use it in GitHub Desktop.
Save alexmags/9226fdce69367319eaa7dd7afbac8fcb to your computer and use it in GitHub Desktop.
Logins with local administrator access report - Defender for Endpoint
DeviceLogonEvents
| where Timestamp >= ago(30d) // last month
| where IsLocalAdmin == 1
// number of machines connected to by the account
| summarize count() by DeviceName, AccountName,LogonType // ,AdditionalFields
| sort by AccountName
// also see https://www.verboon.info/2020/09/hunting-for-local-group-membership-changes/
// https://blog.alexmags.com/tags/kql/
@mohammadakhateeb
Copy link

Thanks Alex for this,
it worked for me and i was looking for just users with interactive login so i add this to the Query but did not work
| where LoginType == Interactive

Cloud you help with this please?

@alexmags
Copy link
Author

Hi Mo
Interactive is a string value so try put it in quotes.
Run the first few lines (before the sumarize command) to get the whole dataset.
Then make it look pretty with project, summarize, sort commands.
Line 3 could be
| where IsLocalAdmin == 1 and LoginType == 'Interactive'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment