Script block logging is a PowerShell security feature that records the contents of script blocks as they run. A script block is a chunk of PowerShell code, whether typed directly, loaded from a file, or built dynamically at execution time. The logs can capture the effective code that PowerShell evaluates, which makes them valuable for detecting malicious commands hidden behind obfuscation, encoding, or one-liners pasted into a terminal.
In cyber security, script block logging helps defenders see what actually executed on an endpoint, not just which process started. That makes it useful for alerting, threat hunting, and post-incident forensics, especially when attackers abuse PowerShell for staging, download-and-execute activity, or hands-on-keyboard operations. Security teams often pair it with module logging, transcription, application control, and centralized log collection so suspicious scripts can be correlated with parent processes and user activity.


