windows 如何在VPNClient中链接Powershell“-Name”

uxhixvfz  于 2023-05-19  发布在  Windows
关注(0)|答案(1)|浏览(237)

我正在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
goqiplq2

goqiplq21#

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
在此测试:

相关问题