我有這樣的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