forked from SEVENP/Sentinel-Queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDevice-SummaryofDeviceLogons.kql
31 lines (30 loc) · 1.49 KB
/
Device-SummaryofDeviceLogons.kql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Create a summary of each device showing all users who have logged on, separated into normal and local admin logons
//Microsoft Sentinel query
DeviceLogonEvents
| where TimeGenerated > ago(30d)
| project DeviceName, ActionType, LogonType, AdditionalFields, InitiatingProcessCommandLine, AccountName, IsLocalAdmin
| where ActionType == "LogonSuccess"
| where LogonType == "Interactive"
| where AdditionalFields.IsLocalLogon == true
| where InitiatingProcessCommandLine == "lsass.exe"
| summarize
['Local Admin Count']=dcountif(AccountName,IsLocalAdmin == "true"),
['Local Admins']=make_set_if(AccountName, IsLocalAdmin == "true"),
['Standard User Count']=dcountif(AccountName, IsLocalAdmin == "false"),
['Standard Users']=make_set_if(AccountName, IsLocalAdmin == "false")
by DeviceName
| sort by ['Local Admin Count'] desc
//Advanced Hunting query
DeviceLogonEvents
| where Timestamp > ago(30d)
| project DeviceName, ActionType, LogonType, AdditionalFields, InitiatingProcessCommandLine, AccountName, IsLocalAdmin
| where ActionType == "LogonSuccess"
| where LogonType == "Interactive"
| where InitiatingProcessCommandLine == "lsass.exe"
| summarize
['Local Admin Count']=dcountif(AccountName,IsLocalAdmin == "true"),
['Local Admins']=make_set_if(AccountName, IsLocalAdmin == "true"),
['Standard User Count']=dcountif(AccountName, IsLocalAdmin == "false"),
['Standard Users']=make_set_if(AccountName, IsLocalAdmin == "false")
by DeviceName
| sort by ['Local Admin Count'] desc