Delete entries from the command history (the commands entered during the current session). Without parameters, Clear-History will delete all commands from the session history.
Syntax
Clear-History [[-Id] Int32[]] [[-Count] int] [-Newest]
[-Confirm] [-WhatIf] [CommonParameters]
Clear-History [[-Count] int] [-CommandLine string[]] [-Newest]
[-Confirm] [-WhatIf] [CommonParameters]
Key:
-CommandLine string[]
Delete commands matching string. If you enter more than one string,
Clear-History will delete commands matching any of the strings.
-Count int
Clear int number of history entries, beginning with the oldest entry
in the history.
If -Id Int32 is given in the same command, Clear-History will begin at Int32.
-Id Int32[]
Delete commands with the specified history ID(s).
To find the history ID of a command, use Get-History.
-Newest
Delete the newest entries in the history.
By default, Clear-History will delete the oldest entries in history.
-confirm
Prompt for confirmation before executing the command.
-whatIf
Describe the command without actually executing it.
Standard Aliases for Clear-History: clhy
The ComputerName may be a NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name. To specify the local computer, type the computer name, a dot (.), or "localhost". -ComputerName does not rely on Windows PowerShell remoting.
Delete all commands from the session history:
PS C:\> Clear-History
Delete the last 10 commands from history:
PS C:\> Clear-History -count 10 -newest
Delete commands with history IDs 10 and 64:
PS C:\> Clear-History -id 10, 64
Delete commands that include "DEL" or end in "windevcluster"
PS C:\> Clear-History -command *DEL*, *windevcluster
Delete 40 items from history, from id=50 to id=11 inclusive, keeping the most recent 10:
PS C:\> Clear-History -id 50 -count 40
“Throughout our history, Microsoft has won by making big, bold bets. I believe that now is not the time to scale back the scope of our ambition or the scale of our investment” ~ Steve Ballmer
Add-History - Add entries to the session history.
Get-History - Get a listing of the session history.