PowerShell Event ID 400: powershell engine started
What PowerShell Event ID 400 (powershell engine started) means, the fields to check, what is normal and what is suspicious, with PowerShell and KQL queries to find it.
Event ID 400 in the Windows PowerShell log is written every time a PowerShell engine starts. It is not exciting on its own, but its HostApplication field holds the full command line, including -EncodedCommand payloads, even on machines without script block logging. Its EngineVersion field also catches downgrade attacks: running PowerShell 2.0 to skip AMSI and script block logging, which only exist from version 5.
The fields that matter
| Field | What it tells you |
|---|---|
| EngineVersion | The engine that started. 2.0 on a modern system almost always means someone forced a downgrade with powershell -version 2. |
| HostApplication | The full command line of the host process, such as powershell.exe -nop -w hidden -enc .... |
| HostName | ConsoleHost for powershell.exe, other values for embedded hosts such as the ISE or automation tools. |
| NewEngineState / PreviousEngineState | Available and None on start. Event 403 records the engine stopping. |
| RunspaceId | Links the start with related events from the same session. |
What is normal
Engine starts with EngineVersion 5.1 (or 7.x for PowerShell 7, which logs elsewhere) from admin consoles, management agents, SCCM or Intune scripts and logon scripts.
When PowerShell Event ID 400 is suspicious
- EngineVersion
2.0on Windows 10, 11 or Server 2016 and later. - HostApplication containing
-enc/-EncodedCommand,-w hidden,-nop,IEX,DownloadStringorFromBase64String. - PowerShell started by Office apps,
wmiprvse.exeor a service, visible when you pair the time with 4688 or Sysmon 1. - A HostName you don't recognise, which can mean PowerShell running inside another program.
Common false positive: Old management tools and legacy scripts sometimes call -version 2 on purpose. Find them and fix them, so a version 2 start becomes a reliable alert.
Find PowerShell Event ID 400 with PowerShell
Get-WinEvent -FilterHashtable @{LogName='Windows PowerShell'; Id=400; StartTime=(Get-Date).AddDays(-7)} |
ForEach-Object {
[pscustomobject]@{
Time = $_.TimeCreated
EngineVersion = [regex]::Match($_.Message, 'EngineVersion=(\S+)').Groups[1].Value
HostApplication = [regex]::Match($_.Message, 'HostApplication=(.+)').Groups[1].Value.Trim()
}
} | Format-List
Microsoft Sentinel (KQL)
Event
| where TimeGenerated > ago(7d) and EventLog == "Windows PowerShell" and EventID == 400
| project TimeGenerated, Computer, RenderedDescription, EventData
| order by TimeGenerated desc
Related events
- PowerShell Event ID 4104: PowerShell script block logged
- Event ID 4688: New process created
- Sysmon Event ID 1: process creation
- Sysmon Event ID 7: image loaded
For a full walk-through, read How to decode and investigate encoded PowerShell commands.
FAQ
Where is PowerShell Event ID 400 logged?
In the classic Windows PowerShell log (Applications and Services Logs > Windows PowerShell), not in Microsoft-Windows-PowerShell/Operational where 4104 lives.
How do I stop PowerShell 2.0 downgrade attacks?
Remove the Windows PowerShell 2.0 feature (Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root). Recent Windows releases no longer include it, but older servers often still do.
Does Event ID 400 show the script that ran?
Only the command line in HostApplication. For the script content, turn on script block logging and read Event ID 4104.
Windows Event Triage reads a CSV, EVTX-to-JSON or XML export in your browser and flags brute force, new admins, suspicious services and log clearing.
IOC Triage, our free browser extension: right-click it for a verdict from 15 threat-intel sources, then copy a ready ticket note.