直接删除 PowerShell 的历史记录文件

直接删除 PowerShell 的历史记录文件

根据不同版本的 PowerShell,历史文件路径如下:

  • Windows PowerShell 5.1
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
  • PowerShell 7
$env:USERPROFILE\.local\share\powershell\PSReadLine\ConsoleHost_history.txt

删除命令示例

Windows PowerShell 5.1:

Remove-Item "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" -Force

PowerShell 7:

Remove-Item "$env:USERPROFILE\.local\share\powershell\PSReadLine\ConsoleHost_history.txt" -Force

⚠️ 如果文件不存在,PowerShell 会报错,可以加上安全参数:

Remove-Item "路径" -Force -ErrorAction SilentlyContinue

这条命令就能彻底删除 PowerShell 历史文件,清空之前的命令记录。

如果你想,我可以帮你写一条自动检测版本并删除对应历史文件的命令,一条就搞定。

No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next