PowerShell's Clear-History doesn't clear history

前端 未结 3 1906
难免孤独
难免孤独 2020-12-12 13:46

Recently I had to run a command that unfortunately required me to type a password right on the command line.

Afterwards, I cleared my screen with \"Clear\", but also

3条回答
  •  离开以前
    2020-12-12 14:31

    To clear the on screen display history (F7) you have to press Alt + F7.

    This history is managed by the console buffer, not by PowerShell that has its history clearable by the Clear-History cmdlet.

    To script it, try:

    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    [System.Windows.Forms.SendKeys]::Sendwait('%{F7 2}')
    

提交回复
热议问题