PowerShell script-block logs
PowerShell operational events can preserve processed script content when logging was available. Script-block logging and interactive command history are different sources with different coverage.
Listen to the full guide
Useful for
Support that the engine logged the recorded script-block content.
Important limit
Guarantee every conditional branch ran or the script completed successfully.
Location & availability
Microsoft-Windows-PowerShell/Operational or PowerShellCore/Operational; commonly event 4104
Availability depends on engine version, provider registration, logging configuration and log retention.
Fields to examine
- ScriptBlockId and script text fragments.
- Message numbering for multi-event script blocks.
- Event time, path and process/runspace context where supplied.
What it can establish
- Support that the engine logged the recorded script-block content.
What it cannot prove
- Guarantee every conditional branch ran or the script completed successfully.
- Treat text containing a suspicious function as proof that function produced an effect.
Worked example
A logged script includes a conditional cleanup branch. The logged text supports that the engine handled that block; it does not prove the branch condition was met. Look for independently recorded effects before claiming deletion.