适用于PPTP和L2TP连接方式:
##########################################################################################
## -------------生成VPN连接.ps1-----------------
## 1. 运行该脚本,可以在网络连接里生成以IM30_VPN为名的连接;
## 2. 有气泡弹框提醒
## 3. 脚本最终解释权,归项目运营IT部所有
##########################################################################################
# 添加VPN,参数-PassThru可显性输出命令的执行信息
Add-VpnConnection -Name IM30_VPN -ServerAddress vpn.im30.net -AllUserConnection -DnsSuffix 10.0.100.5 -RememberCredential -TunnelType Pptp -PassThru
#加载 Winform 程序集,使用Out-Null抑制输出
[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
#创建 NotifyIcon 对象
$balloon = New-Object System.Windows.Forms.NotifyIcon
$path = Get-Process -id $pid | Select-Object -ExpandProperty Path
$icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balloon.Icon = $icon
$balloon.BalloonTipIcon = 'Info'
$balloon.BalloonTipText = 'IM30_VPN已创建完毕,请连接吧!'
$balloon.BalloonTipTitle = '温馨提示'
$balloon.Visible = $true
#显示气球提示框
$balloon.ShowBalloonTip(10000)