Skip to main content

Clear PowerShell History

Anti-forensics
technique
Updated 30 November 2026

A subject deliberately deletes, clears, or suppresses PowerShell command history to hinder reconstruction of commands executed during activities associated with an infringement. Interactive PowerShell sessions may retain command history through the PSReadLine module. On Windows, the default history file for the ConsoleHost is commonly located at %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt, although the location and persistence behavior depend on the environment and configuration. The subject may remove the history file, modify PSReadLine settings, or otherwise interfere with the persistence of commands. Clearing the active session's history through Clear-History does not necessarily remove commands retained in the PSReadLine history file. Investigators should establish whether command history was expected to exist and correlate any gaps with PowerShell logging, process execution records, endpoint telemetry, and other available evidence. Missing history does not independently establish deliberate deletion.

1
Prevention Strategies
3
Detection Methods
0
Tactics
2
Contributors

Prevention Strategies (1)

No Ready System-Level Mitigation

This section cannot be readily mitigated at a system level with preventive controls since it is based on the abuse of fundamental features of the system.

From the Matrix:

This section cannot be readily mitigated at a system level with preventive controls since it is based on the abuse of fundamental features of the system....

Detection Methods (3)

ConsoleHost_history.txt Created Timestamp Discrepancy

Recent modifications to the ConsoleHost_history.txt file located in C:\Users\%username%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine may indicate the file has been deleted and subsequently automatically recreated by the Operating System. This may represent an anti-forensics technique if the subject in question is known to have used PowerShell any time prior to the “Created” timestamp of the ConsoleHost_history.txt file.

ConsoleHost_history.txt File Missing

If the ConsoleHost_history.txt file located in C:\Users\%username%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine, is missing, this indicates that the file has been deleted. This may represent an anti-forensics technique if the subject in question is known to have used PowerShell any time.

PowerShell Logging

Detailed PowerShell logging is not enabled by default and must be configured.PowerShell is able to record the processing of commands, script blocks, functions, and scripts whether invoked interactively, or through automation. PowerShell logging can be enabled through Group Policy with the following: Administrative Templates → Windows Components → Windows PowerShell There are 3 available logging types, they are: Module Logging, Script Block Logging and Transcription. Module Logging: Records pipeline execution details, such as variable initialisation and command invocations, capturing portions of scripts and some de-obfuscated code. This logging is available since PowerShell 3.0 and generates a large volume of events, providing valuable output not captured elsewhere. Events are written to Event ID 4103. Module logging can be enabled by setting the following registry values: HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ModuleLogging → EnableModuleLogging = 1 HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ModuleLogging \ModuleNames → * = * Script Block Logging: Captures blocks of code as they are executed, including de-obfuscated code, allowing visibility into the full contents of executed scripts and commands. This feature is available in PowerShell 5.0 and records events under Event ID 4104. Script block logging can be enabled by setting the following registry values: HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging → EnableScriptBlockLogging = 1 Transcription: Records the input and output of entire PowerShell sessions, providing a comprehensive record of all commands executed and their results. Transcription logging can be enabled by setting the following registry values: HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription → EnableTranscripting = 1 HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription → EnableInvocationHeader = 1 HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription → OutputDirectory = “” (Enter path. Empty = default)

Contributors

Forscie® Limited
The ITM Team

Our pillar mapping

Our own keyword match of each prevention and detection to the Insider Risk Index's five pillars. It is not part of the Forscie Matrix and not a measured value.

Visibility
1
Prevention & Coaching
Investigation & Evidence
2
Identity & SaaS
Phishing Resilience

Attribution

This technique is part of the Forscie® Insider Threat Matrix™. Copyright 2026 Forscie® Limited. Licensed under Apache License 2.0.

View on Forscie® Insider Threat Matrix™
Clear PowerShell History | Insider Risk Index