Query Details
# Hunt for Local Admins with the most RemoteInteractive logins ---- ### Defender For Endpoint ``` DeviceLogonEvents | where IsLocalAdmin == "True" | where LogonType == "RemoteInteractive" | extend IsLocalLogon = tostring(todynamic(AdditionalFields).IsLocalLogon) | summarize DevicesAccessed = make_set(DeviceName) by AccountName, AccountDomain | extend TotalDevices = array_length(DevicesAccessed) | sort by TotalDevices ``` ### Sentinel ``` DeviceLogonEvents | where IsLocalAdmin == "True" | where LogonType == "RemoteInteractive" | extend IsLocalLogon = tostring(todynamic(AdditionalFields).IsLocalLogon) | summarize DevicesAccessed = make_set(DeviceName) by AccountName, AccountDomain | extend TotalDevices = array_length(DevicesAccessed) | sort by TotalDevices ```
This query is searching for local administrators who have the most logins using the "RemoteInteractive" logon type. It retrieves the device logon events, filters for local administrators and the specified logon type, and then groups the results by the account name and domain. It calculates the number of devices accessed by each account and sorts the results by the total number of devices accessed.

Bert-Jan Pals
Released: February 14, 2023
Tables
Keywords
Operators