0

If i press the up arrow in powershell the last command shows up. Other programs delete this "history" but it seems like powershell doesn't. I would like to know how to remove this data ( a restart doesn't work ).

  • Does this answer your question? [PowerShell's Clear-History doesn't clear history](https://stackoverflow.com/questions/13257775/powershells-clear-history-doesnt-clear-history) – Theo Mar 12 '20 at 12:23

2 Answers2

0

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/clear-history?view=powershell-7

Using the command Clear-History "deletes the command history from a PowerShell session."

PowerShell's Clear-History doesn't clear history

"[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory() can be used to clear the current session's history"

midacts
  • 196
  • 6
  • I tested this, it won't work. Clear-History PowerShell's own history mechanism (Get-History, Clear-History) is host-independent, which is why - somewhat unexpectedly - you also need to clear the hosts's command history separately. --> https://stackoverflow.com/questions/13257775/powershells-clear-history-doesnt-clear-history – Nicicalu Mar 12 '20 at 11:57
  • `[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()` can be used to clear the current session's history. – midacts Mar 12 '20 at 11:59
-1

You can clear this history by pressing Alt + F7. This is the most simple way, without a command.


Edit: Thanks to Midacts for pointing out the command for this purpose:

[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()

For more information you may want to take a look at this post: PowerShell's Clear-History doesn't clear history

Nicicalu
  • 759
  • 7
  • 16