- 安装新版本:
iex "& { $(irm https://aka.ms/install-powershell.ps1 -UseBasicParsing) }"
- 设为默认版本
注意不是PowerShell里的Alias别名
- 创建Powershell配置文件,若已创建则跳过
New-Item $profile -force -itemtype file
notepad $profile
编辑配置文件- 按如下格式添加命令
function 别名 { 需要替代的命令 }
eg.
remove-item alias:history # 可选,删除默认的别名,否则会先调用默认的
function history { cat C:\Users\xxx\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt }
- 然后执行
Set-ExecutionPolicy RemoteSigned
生效更改 - 重启PowerShell即可