微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用于 Windows VPN 创建问题的 Powershell 脚本

如何解决用于 Windows VPN 创建问题的 Powershell 脚本

让我先介绍一下,我不精通 PS 脚本,所以请对我放轻松!

我们正在尝试根据员工在 AD 中关联的特定 OU 向他们部署基于位置的 VPN 连接。因此,我们创建了一个通过 Intune 推送的 VPN 配置模板。如果有帮助,我们就是 Meraki 环境。

$ProfileName = 'Identifiable Site Name'
$ServerAddress = 'vpn-site.company.com'

Remove-Item -path "c:\users\*\AppData\Roaming\Microsoft\Network\Connections\pbk\" -force -Recurse
Remove-item -path "C:\Users\*\*\$ProfileName.lnk" -force
foreach ($vpn in get-vpnconnection){rasdial $vpn.name /disCONNECT; Remove-VpnConnection -Name $vpn.name -force}
Start-Sleep -s 5
foreach ($vpn in get-vpnconnection -AllUserConnection){rasdial $vpn.name /disCONNECT; Remove-VpnConnection -Name $vpn.name -force}
    
Write-Host "Profiles Removed,Links Decimated,Registry Registered"

#Create connection,wait 10 seconds to process,and set DHgroup 14 peramaters 
Add-VpnConnection -Name $ProfileName -ServerAddress $ServerAddress -AuthenticationMethod MSChapv2,PAP -EncryptionLevel required -Force -L2tpPsk PSK-Private -RememberCredential -TunnelType L2tp 
Start-Sleep -s 10
Set-VpnConnectionIPsecConfiguration -AuthenticationTransformConstants SHA196 -CipherTransformConstants AES128 -ConnectionName $ProfileName -DHGroup Group14 -EncryptionMethod AES128 -IntegrityCheckMethod SHA1 -PfsGroup None -force

# Create registry key to allow connections to an MX behind NAT (Error 809)
New-ItemProperty -Path HKLM:\SYstem\CurrentControlSet\Services\PolicyAgent -Name AssumeUDPEncapsulationContextOnSendRule -Value 2 -PropertyType DWORD -Force | Out-Null


# Create a desktop shortcut
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut("$env:Public\Desktop\$ProfileName.lnk")
$Shortcut.TargetPath = "rasphone.exe"
$Shortcut.IconLocation = "https://iconlocation.com/icon.ico,0"
$Shortcut.Save()

但是,无论何时我们通过 Intune 或通过管理 Powershell 部署,我们都会得到预期的桌面图标,但在 RAS 电话簿中没有 VPN 配置。我找不到任何事件日志或任何阻止执行的内容

任何帮助或见解将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。