Query Details
let _SuccessResultTypes = toscalar(
_GetWatchlist("ResultType-SignInLogsErrorCodes")
| where Notes has_all ("[Success]", "[Complete]") and isnotempty(ResultDescription)
| summarize make_list(ResultType)
);
let _PowerShellAppExpectedResource =
_GetWatchlist("Activity-ExpectedSignificantActivity")
| where Activity == "PowerShellAppExpectedResource"
| project AppId = tostring(SourceResource), ResourceIdentity = tostring(DestinationResource)
;
SignInLogsTables
| where ResultType in (_SuccessResultTypes)
| where AppDisplayName has_any ("CLI", "PowerShell", "Management Shell")
| join kind=leftanti _PowerShellAppExpectedResource on AppId, ResourceIdentity
| invoke UnifySignInLogs()
| project
TimeGenerated,
CreatedDateTime,
Category,
UserPrincipalName,
UserDisplayName,
IPAddress,
Location,
ResultType,
AppDisplayName,
ResourceDisplayName,
AppId,
ResourceIdentity,
ResourceTenantId,
ClientAppUsed,
UserAgent,
Status,
LocationDetails,
DeviceDetail,
AuthenticationDetails,
AuthenticationProcessingDetails,
OriginalRequestId,
CorrelationId
This query retrieves sign-in logs data and filters it based on certain conditions.
First, it gets a list of success result types from a watchlist called "ResultType-SignInLogsErrorCodes" that have notes containing both "[Success]" and "[Complete]" and have a non-empty result description.
Then, it gets a list of expected significant activities from another watchlist called "Activity-ExpectedSignificantActivity" where the activity is "PowerShellAppExpectedResource" and projects the app ID and resource identity.
Next, it filters the sign-in logs tables based on the success result types obtained earlier, where the app display name contains either "CLI", "PowerShell", or "Management Shell".
After that, it performs a left anti join with the expected PowerShell app resources based on the app ID and resource identity.
Then, it invokes the "UnifySignInLogs" function.
Finally, it projects various columns from the sign-in logs data.

Jose Sebastián Canós
Released: October 10, 2023
Tables
Keywords
Operators