命令行中的IP范围
我希望在Windows 7 Ultimate 32位中使用Powershell和Task Scheduler在VPN连接断开时重拨VPN。我找到了一个脚本(http://blog.degree.no/2011/10/permanent-vpn-connection-in-windows/),但是它只有一个IP地址。由于我的vpn分配IP地址的方式,我需要的是IP地址范围,如10.0.0.0/16。谁能帮我吗? 创建c:\pn.ps1并添加以下内容: $ip = "10.20.30.40" $result = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$ip'" if ($result.StatusCode -eq 0) { Write-Host "$ip is up." } else{ Write-Host "$ip is down." Write-Host "Disconnecting..." rasdial.exe DegreeVPN /DISCONNECT Write-Host "Connecting..." rasdial.exe DegreeVPN vpnUsername vpnPassword12345 }