Files
cheatsheet-tldr/tldr/windows/clear-history
2025-10-31 00:20:00 +00:00

43 lines
961 B
Plaintext

---
syntax: markdown
tags: [tldr, windows]
source: https://github.com/tldr-pages/tldr.git
---
# Clear-History
> A powershell command to clear the entries in the current session.
> Note: `clhy` can be used as an alias for `Clear-History`.
> More information: <https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/clear-history>.
- Clear all command history from current session:
`Clear-History`
- Clear command by specific name:
`Clear-History -CommandLine "{{command}}"`
- Clear multiple commands by name:
`Clear-History -CommandLine "{{command_1}}", "{{command_2}}"`
- Clear a specific history entry by ID:
`Clear-History -Id {{id_number}}`
- Clear multiple IDs:
`Clear-History -Id {{id_1}}, {{id_2}}, {{id_3}}`
- Clear commands within a range of IDs:
`Clear-History -Id ({{start_id}}..{{end_id}})`
- Show what would be deleted:
`Clear-History -WhatIf`
- Ask for confirmation before clearing:
`Clear-History -Confirm`