Skip to content

Remove PSReadLineHistory

viscalyxbot edited this page Aug 4, 2024 · 1 revision

Remove-PSReadLineHistory

SYNOPSIS

Removes content from the PSReadLine history that matches a specified pattern.

SYNTAX

Remove-PSReadLineHistory [-Pattern] <String> [-EscapeRegularExpression] 
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

The Remove-PSReadLineHistory function removes content from the PSReadLine history that matches a specified pattern.

EXAMPLES

EXAMPLE 1

Remove-PSReadLineHistory -Pattern ".*\.txt"

This example removes all command history entries that end with the ".txt" extension, using a regular expression pattern.

EXAMPLE 2

Remove-PSReadLineHistory -Pattern './build.ps1' -EscapeRegularExpression

This example removes all command history entries that contain the string "./build.ps1".

PARAMETERS

-EscapeRegularExpression

Indicates that the pattern should be treated as a literal string. If this switch parameter is specified, the pattern will not be treated as a regular expression.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Pattern

Specifies the pattern to match against the command history entries. Only the entries that match the pattern will be removed.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None. You cannot pipe input to this function.

OUTPUTS

None. The function does not generate any output.

NOTES

  • This command requires the PSReadLine module to be installed.
  • The PSReadLine history is stored in a file specified by the HistorySavePath property of the PSReadLineOption object.

RELATED LINKS

Clone this wiki locally