NAME
Clear-History
SYNOPSIS
Deletes entries from the command history.SYNTAX
Clear-History [[-Count]
] [-CommandLine ] [-Confirm] [-Newest] [-WhatIf] [ ] Clear-History [[-Id]
] [[-Count] ] [-Confirm] [-Newest] [-WhatIf] [ ] DESCRIPTION
The Clear-History cmdlet deletes commands from the command history, that is, the list of commands entered during
the current session.Without parameters, Clear-History deletes all commands from the session history, but you can use the parameters of
Clear-History to delete selected commands.
PARAMETERS
-CommandLine
Specifies commands that this cmdlet deletes. If you enter more than one string, Clear-History deletes commands
that have any of the strings. Required? false Position? named Default value None Accept pipeline input? False Accept wildcard characters? false-Confirm [
Prompts you for confirmation before running the cmdlet. Required? false Position? named Default value False Accept pipeline input? False Accept wildcard characters? false] -Count
Specifies the number of history entries that this cmdlet clears, starting with the oldest entry in the history. If you use the Count and Id parameters in the same command, the cmdlet clears the number of entries specified by the Count parameter, starting with the entry specified by the Id parameter. For example, if Count is 10 andId is 30, Clear-History clears items 21 through 30 inclusive.
If you use the Count and CommandLine parameters in the same command, Clear-History clears the number of
entries specified by the Count parameter, starting with the entry specified by the CommandLine parameter. Required? false Position? 1 Default value None Accept pipeline input? False Accept wildcard characters? false-Id
Specifies the history IDs of commands that this cmdlet deletes.To find the history ID of a command, use the Get-History cmdlet.
Required? false Position? 0 Default value None Accept pipeline input? False Accept wildcard characters? false-Newest [
] Indicates that this cmdlet deletes the newest entries in the history. By default, Clear-History deletes the
oldest entries in the history. Required? false Position? named Default value False Accept pipeline input? False Accept wildcard characters? false-WhatIf [
Shows what would happen if the cmdlet runs. The cmdlet is not run. Required? false Position? named Default value False Accept pipeline input? False Accept wildcard characters? false] This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). INPUTS
None You cannot pipe objects to this cmdlet.OUTPUTS
None This cmdlet does not generate any output.NOTES
* The session history is a list of the commands entered during the session. You can view the history, add and
delete commands, and run commands from the history. For more information, see about_History.* Deleting a command from the history does not change the history IDs of the remaining items in the command
history.*
Example 1: Delete all commands
PS C:\>Clear-History
This command deletes all commands from the session history.Example 2: Delete commands by using history IDs
PS C:\>Clear-History -Id 23, 25
This command deletes the commands that have history IDs 23 and 25.Example 3: Delete specific commands
PS C:\>Clear-History -Command *help*, *command
This command deletes commands that include "help" or end in "command".Example 4: Delete the newest commands
PS C:\>Clear-History -Count 10 -Newest
This command deletes the 10 newest commands from the history.Example 5: Delete the oldest commands
PS C:\>Clear-History -Id 10 -Count 3
This command deletes the three oldest commands, starting with the entry with ID 10.RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821470Add-History
Get-History
Invoke-History