Event ID 4106: Stopped invoking a command (script block)
Marks the end of execution of a script block. The closing bracket to 4105.
- Channel
- Microsoft-Windows-PowerShell/Operational
- Logged by default
- No
- Written on
- Any host
- Volume
- Very high
- Provider
- Microsoft-Windows-PowerShell
- Needs a SACL
- No
To have this event
- Script block logging with invocation logging enabled
Key fields
Exact XML field names, as they appear in <Data Name="…"> and in SIEM field extractions.
| Field | What it tells you |
|---|---|
| ScriptBlockId | GUID of the script block that finished; join to the matching 4105 and to 4104 |
| RunspaceId | Runspace in which the block executed |
Analyst notes
- 01Use the 4105/4106 pair to measure how long a block ran and to confirm execution versus compilation.
- 02Very high volume; keep 4104 as the primary signal.
Pull this event
Retrieval queries for a live host, a collected .evtx file and common SIEMs. Filter further on the key fields above.
Get-WinEvent -LogName 'Microsoft-Windows-PowerShell/Operational' -FilterXPath "*[System[(EventID=4106)]]" -MaxEvents 50 |
Select-Object TimeCreated, Id, MachineName, Message-FilterXPath supports exact matches only. For substring matching, filter in Where-Object.
ATT&CK mapping
Techniques this event can help detect. Most of these depend on specific field values; the event alone does not mean the technique happened.
Related events
Common questions
- What does Windows event ID 4106 mean?
- Marks the end of execution of a script block. The closing bracket to 4105. It is written to the PowerShell Operational log (Microsoft-Windows-PowerShell/Operational).
- Is event 4106 logged by default?
- No. It must be enabled before it is recorded.
- Where is event 4106 recorded?
- In the Microsoft-Windows-PowerShell/Operational channel on the any host.
Decode a real event
Paste the XML and every value gets explained. Nothing leaves your browser.
Open decoderMarks the end of execution of a script block. The closing bracket to 4105. Key fields, logging requirements, ATT&CK mapping and ready-to-run queries.