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.
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.
Delete commands with the specified history ID(s).
To find the history ID of a command, use Get-History.
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. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
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:
Delete the last 10 commands from history:
C:\PS>clear-history -count 10 -newest
Delete commands with history IDs 10 and 64:
C:\PS>clear-history -id 10, 64
Delete commands that include "DEL" or end in "SS64"
C:\PS>clear-history -command *DEL*, *SS64
Delete 40 items from history, from id=50 to id=11 inclusive, keeping the most recent 10:
C:\PS>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
© Copyright SS64.com 1999-2013
Some rights reserved