Cloud app activity for specific users – with device context
Shows everything a set of users did across Microsoft 365 and connected cloud apps, with IP, country, OS, device type and the managed/compliant flag. Useful for investigating a single user or checking where and from which kind of device someone works.
// === Parameters ===
let TargetUsers = dynamic(["<user-object-id-1>", "<user-object-id-2>"]); // Entra ID object IDs
let Lookback = 7d;
CloudAppEvents
| where Timestamp > ago(Lookback)
| where AccountObjectId in (TargetUsers)
…
Devices still running Visual Studio 2015 / 2017
Finds devices where Visual Studio 2015 or 2017 (devenv.exe) was actually launched in the last 30 days, with users, install paths, run counts and device group. Separates real usage from installs nobody opens – the evidence you need before removing old versions.
let Lookback = 30d;
DeviceProcessEvents
| where Timestamp > ago(Lookback)
| where FileName =~ "devenv.exe"
| extend VSVersion = case(
ProcessVersionInfoProductVersion startswith "14." or FolderPath contains "Microsoft Visual Studio 14.0", "VS2015",
…
Devices with third-party antivirus / EDR installed
Uses the Defender Vulnerability Management software inventory to find devices that still have a non-Microsoft antivirus or EDR product installed, with logged-on user and device group. Handy for AV migrations to Defender and for finding leftovers after uninstalls.
// === Parameters ===
// Vendor/product keywords. The ( ^|[^a-z] ) boundaries stop short names like "eset" or "avg" matching inside other words (e.g. "preset").
let AVPattern = @"(?i)(^|[^a-z])(bitdefender|symantec|mcafee|trellix|sophos|eset|kaspersky|trend_?micro|crowdstrike|sentinel_?one|avast|avg|norton|webroot|malwarebytes|panda|f-?secure|avira|g_?data|cylance|carbon_?black)([^a-z]|$)";
let DevicePrefix = ""; // optional, e.g. "ws-" – leave empty for all devices
DeviceTvmSoftwareInventory
| where SoftwareName matches regex AVPattern or SoftwareVendor matches regex AVPattern
…
PowerShell launched with an encoded command
Finds PowerShell processes started with a Base64 encoded command (-e, -enc, -EncodedCommand). This is a common way attackers hide what a script does, though some admin tools use it legitimately.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine matches regex @"(?i)\s-e[a-z]*\s+[a-z0-9+/=]{20,}"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine
…
Users running Visual Studio 2015 / 2017 – per-user summary
The same detection as the per-device query, rolled up per user: which devices each person uses old Visual Studio on, how often, and when they last did. Gives you the contact list for a migration or removal campaign.
let Lookback = 30d;
DeviceProcessEvents
| where Timestamp > ago(Lookback)
| where FileName =~ "devenv.exe"
| extend VSVersion = case(
ProcessVersionInfoProductVersion startswith "14." or FolderPath contains "Microsoft Visual Studio 14.0", "VS2015",
…
No queries match your search.
