• 当前 PowerShell 主机应用程序中使用以下命令为当前用户创建配置文件

  • 使用“以管理员身份运行”选项启动 PowerShell,创建所有用户配置文件

if (!(Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}

执行完成会给出配置文件地址:C:\Users\chen\Documents\WindowsPowerShell,找到文件并记事本打开填入以下内容:

Set-PSReadLineOption -HistorySaveStyle SaveNothing

然后执行这个命令为计算机设置执行策略:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

如果不需要了可以使用这个命令删除执行策略:

Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope LocalMachine