powershell实现离线ip扫描

1.实现方式

powershell

ps:shell也同样可以实现

 

2.脚本

$ip = "192.168.50."
for ($i = 1; $i -lt 255; $i ++) {
# get each ip
$cur = $ip + $i
# ping once 
ping -n 1 $cur | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host "$cur 在线"
} else {
Write-Host "$cur 离线"
}
}

3.执行效果

 

posted on 2017-07-07 11:04  alexgq  阅读(246)  评论(0)    收藏  举报

导航