我有这样的PowerShell脚本来检查未使用的IPPowerShell的IP扫描仪
$ipgroupes = "192.168.2"
$ipstart = 1
$ipend = 255
$ipstart..$ipend | ForEach-Object{
$ip = "$ipgroupes.0" -replace "0$",$_
If (-not(Resolve-DnsName -Name $ip -QuickTimeout -Type ANY -ErrorAction
SilentlyContinue) -And (!(Test-Connection $ip -count 1 -quiet)))
{
write-host "$ip is not used" -ForegroundColor Green
}
}
脚本工作正常,但我一直在问从搜索中排除的IP 80到149。我需要如何完成这项工作的帮助?
你可以做'1..79 + 150..255 | ForEach-Object {',(但它不像具有“排除范围”那样灵活)。 – TessellatingHeckler