将 PowerShell 7 设置为Windows Terminal默认项

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

问题描述

Windows10 默认使用PowerShell 5在安装PowerShell 7之后不知道该怎么使用/切换到PowerShell 7。

如何使用PowerShell 7

Windows10 新安装的PowerShell 7不会取代旧版本而是与旧版本并存有两种方法能够使用PowerShell 7。

方法1用PowerShell 7运行脚本

还从原来的PowerShell或者Windows Terminal启动启动后提示信息应该是

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

尝试新的跨平台 PowerShell https://aka.ms/pscore6

这说明当前使用的是旧版本PowerShell 5。若想以PowerShell 7运行脚本则使用pwsh命令例如pwsh .\test.ps1

方法2直接使用PowerShell 7程序

安装PowerShell 7后在开始-所有应用里面就会出现一个新的软件PowerShell 7(x64)直接运行这个软件就是PowerShell 7。
如果使用Windows Terminal在顶部的下拉菜单里选择PowerShell如图
在这里插入图片描述
若命令行提示PowerShell 7.3.2就说明当前用的是PowerShell 7。

设置为Windows Terminal默认项

在Windows Terminal设置默认启动项即可
在这里插入图片描述

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: windowsshell