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

如何在PowerShell中通过-Name参数访问全用户VPN连接?

解决PowerShell查询全局VPN连接时的"找不到连接"问题

问题原因

通过-AllUserConnection参数创建的是系统全局VPN连接,这类连接存储在系统级配置中,而非当前用户的个人配置目录里。直接使用Get-VpnConnection -Name时,PowerShell默认只搜索当前用户的VPN连接池,因此会触发"找不到连接"的错误。

解决方案

查询全局VPN连接时,必须同时指定-Name和-AllUserConnection参数,命令示例:

Get-VpnConnection -Name "USERVPN" -AllUserConnection

操作对比示例

错误操作(未指定全局参数)

PS C:\WINDOWS\system32> Get-VpnConnection -Name "USERVPN"
Get-VpnConnection :  VPN connection USERVPN was not found. : The system could not find the phone book entry for this connection.
At line:1 char:1
+ Get-VpnConnection -Name "USERVPN"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (USERVPN:root/Microsoft/...S_VpnConnection) [Get-VpnConnection], CimException
    + FullyQualifiedErrorId : VPN 623,Get-VpnConnection

正确操作(指定全局参数)

PS C:\WINDOWS\system32> Get-VpnConnection -Name "USERVPN" -AllUserConnection

Name                  : USERVPN
ServerAddress         : 123.456.789.123
AllUserConnection     : True
Guid                  : {8119DEDB-B9C1-4660-B3EA-5F14B0B2205D}
TunnelType            : L2tp
AuthenticationMethod  : {Pap}
EncryptionLevel       : Optional
L2tpIPsecAuth         : Psk
UseWinlogonCredential : False
EapConfigXmlStream    :
ConnectionStatus      : Disconnected
RememberCredential    : False
SplitTunneling        : False
DnsSuffix             :
IdleDisconnectSeconds : 0

额外提示

所有针对全局VPN的后续操作(如修改配置、删除连接),都需要带上-AllUserConnection参数,否则PowerShell会默认操作当前用户的个人VPN连接池。

内容的提问来源于stack exchange,提问作者Jean-François Ramier

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 22:32:51