You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

远程连接始终进入PowerShell 5.1,如何切换至PowerShell 7.3?

如何远程连接PowerShell 7.3而非5.1

方法1:创建会话时指定PowerShell 7的配置名称

默认情况下,New-PSSession会使用PowerShell 5.1的默认会话配置(Microsoft.PowerShell)。PowerShell 7安装后会自动注册专属的会话配置,名称通常为PowerShell.7(若安装了多个小版本,可能会有PowerShell.7.3这类更具体的名称)。

修改你的连接命令,添加-ConfigurationName参数即可指定连接到PowerShell 7:

$sess = New-PSSession -ComputerName server01 `
                      -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) `
                      -Credential $cred `
                      -ConfigurationName PowerShell.7

Enter-PSSession -Session $sess

若不确定远程机器上的PowerShell 7配置名称,可先在远程机器上执行以下命令查看:

Get-PSSessionConfiguration | Where-Object Name -like "PowerShell.7*"

方法2:设置全局默认会话配置(可选)

如果希望每次从本地PowerShell 7发起远程连接时都默认使用PowerShell 7的端点,可以设置本地的$PSSessionConfigurationName变量:

# 当前会话临时生效
$PSSessionConfigurationName = "PowerShell.7"

# 永久生效(写入用户配置文件)
Add-Content -Path $PROFILE -Value '$PSSessionConfigurationName = "PowerShell.7"'

之后执行New-PSSession时就无需手动指定-ConfigurationName参数了。

注意事项

  • 确保远程机器上的PowerShell 7已正确启用远程功能:你已在PS7中执行过Enable-PSRemoting,这一步是注册PS7会话配置的必要操作。
  • 若远程机器存在多个PowerShell 7小版本(如7.2和7.3),可指定具体配置名称(如PowerShell.7.3)来精准连接目标版本。

内容的提问来源于stack exchange,提问作者Alex F

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 21:25:18