命令行中的IP范围


1

我希望在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
}

您想传递什么脚本?一个子网和一个地址?
soandos

我想插入IP范围,因此要插入10.0.0.0到10.255.255.255之间的所有IP,而不是上面的脚本中的10.20.30.40。
dreamerman
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.