PowerShell Logging Overview and Practices
PowerShell Logging Overview and Practices
Transcription logging is unique because it doesn't appear in Windows event logs but is instead written out to files in the C:\Users\IEUser\PSTranscripts directory. It provides a comprehensive view of commands entered and outputs seen during a session, akin to 'over the shoulder' logging .
Starting a new PowerShell session after changing logging settings ensures that the new configurations are applied and any newly executed commands are logged accurately. This practice maintains log integrity, ensuring that logs reflect the latest configuration settings and capture relevant data .
PowerShell logging can be modified by changing specific registry keys or using Group Policy to enable more detailed logging such as script block, module, and transcription logging. This is facilitated through tools like the LogMenu to easily turn logging on or off, requiring a new PowerShell session to apply these changes .
PowerShell logging helps identify downgrade attacks by logging engine lifecycle events, noting the version in use. If an older version is being used, it may indicate a downgrade attack, as older versions lack advanced logging and security features, thus making it easier to bypass security mechanisms .
Suspicious Script Block Logging identifies script blocks as suspicious if they contain certain keywords like Add-Type, GetField, or NonPublic. When such keywords are detected, the system logs these scripts as suspicious events, like event ID 800, helping to detect potentially harmful operations .
By default, PowerShell logging includes two primary types: Engine and Provider Lifecycle Events, and Suspicious Script Block Logging . Users can enable three additional log types: Script Block Logging, Module Logging, and Transcription Logging to enhance security monitoring .
Script Block Invocation Logging is often excluded because it is very noisy and not particularly helpful for most monitoring scenarios. This verbosity can overwhelm administrators with excessive log data, making it challenging to pinpoint actionable insights amid false positives .
To achieve more granular security insights, environments can enable optional logging types like Script Block, Module, and Transcription Logging. The LogMenu tool facilitates these settings by allowing easy toggling of logging options and requires a restart of the PowerShell session for changes to take effect .
Users should close Visual Studio Code when monitoring PowerShell logs to prevent interference since Visual Studio Code executes PowerShell commands in the background. This activity can cause confusion by cluttering logs with unnecessary events .
Real-time viewing of PowerShell logs is enhanced by using tools like TailPSopLog, which allows users to view events without the need for manual refreshing. It displays different types of logs with color coding to distinguish between log types, such as module logs in blue and warning-level script block logs in dark yellow .