我正在 Powershell 中创建一个 VPN。
我想通过
-AllEuserConnection
获取有关此 VPN 的信息,但是当尝试通过 -Name
显示时出现错误。我尝试了多种名称变体,但都没有成功。我需要按名称访问才能在 VPN 上执行另一个命令。
这是我得到的错误示例:
PS C:\WINDOWS\system32> Add-VpnConnection -Name "USERVPN" -ServerAddress "123.456.789.123" -TunnelType L2tp -AuthenticationMethod Pap -EncryptionLevel Optional -L2tpPsk "UserKey" -Force -AllUserConnection
WARNING: The currently selected encryption level requires EAP or MS-CHAPv2 logon security methods. Data encryption will
not occur for Pap or Chap.
PS C:\WINDOWS\system32> Get-VpnConnection -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
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], CimExce
ption
+ FullyQualifiedErrorId : VPN 623,Get-VpnConnection
在
Add-VpnConnection
Cmdlet 上,您正在使用开关参数 -AllUserConnection
,因此您还需要在 Get-VpnConnection
上调用它。
Add-VpnConnection -Name "USERVPN" -ServerAddress "123.456.789.123" -TunnelType L2tp -AuthenticationMethod Pap -EncryptionLevel Optional -L2tpPsk "UserKey" -Force -AllUserConnection
Get-VpnConnection -Name USERVPN -AllUserConnection
您还需要在其他 Cmdlet 上调用它,例如
Remove-VpnConnection
.