Audit Powershell Scriptblock
Some detection rules require enabling PowerShell Script Block Logging to record the content of processed script blocks in the Windows Event Log.
To collect these logs, use the Windows Integration and select the Powershell Operational channel on the integration setup page.
To enable PowerShell Script Block logging across a group of servers using Active Directory Group Policies, administrators must enable the Turn on PowerShell Script Block Logging policy. Follow these steps to implement the logging policy:
Computer Configuration >
Administrative Templates >
Windows PowerShell >
Turn on PowerShell Script Block Logging (Enable)
To configure the audit on servers that aren't domain joined, the EnableScriptBlockLogging registry key must be set to 1. Here is an example modification command:
reg add "hklm\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" /v EnableScriptBlockLogging /t REG_DWORD /d 1
When this audit policy is enabled, the following event IDs may be generated in the Microsoft-Windows-PowerShell/Operational log:
- 4104: Script block execution.
Use the following GitHub search to identify rules that use the events listed: