Detect PowerShell v2 Downgrade
Description
This query looks for processes that load an older version of the system.management.automation libraries. While not inherently malicious, downgrading to PowerShell version 2 can enable an attacker to bypass some of the protections afforded by modern PowerShell. It is worth noting that some tools and scripts perform this to enable backwards compatibility, so the technique is not inherently malicious. You will likely need to filter the processes within your environment that legitimately use this capability for this to be effective.
Query · kql
DeviceImageLoadEvents
| where InitiatingProcessFileName =~ 'powershell.exe'
and FileName in~ ('system.management.automation.ni.dll','System.Management.Automation.dll')
and FolderPath matches regex @"[12]\.(\d)+\.(\d)+\.(\d)+"