方法一:输入的时候按“向右箭头”按键,即可补全命令。
方法二:按“F2”按键,即可获得历史命令,向上或向下按钮可高亮和补全命令。

方法三:使用以下命令获得所有历史命令:
Get-Content (Get-PSReadlineOption).HistorySavePath
如果要使用类似于linux的grep,则在后面使用管道命令和通配符筛选,比如以下命令筛选含有“dism”字符串的命令:
Get-Content (Get-PSReadlineOption).HistorySavePath | ? { $_ -like '*dism*' }

参考资料:
1、https://www.reddit.com/r/PowerShell/comments/ytkqch/ps_suddenly_has_autocomplete_how_to_use_it/
本页永久链接:https://www.orztip.com/?p=850&article_title=powershell-get-history-and-auto-complete