Powershell IP扫描仪

时间:2016-05-06 17:16:29

标签: powershell

我有这个powershell脚本来检查未使用的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 个答案:

答案 0 :(得分:2)

试试这个。要撤消排除,您可以将两个排除值都设置为0

dat <- structure(list(detected_id = c(11, 11, 11, 11, 12, 4), reviewer_name = c("Mike", 
"Mike", "Mike", "Mike", "John", "John"), created_at = c("2016-05-04 10:02:45", 
"2016-05-04 10:02:45", "2016-05-04 10:02:45", "2016-05-04 10:02:45", 
"2016-05-04 10:02:45", "2016-05-04 10:02:45"), stage = c(2L, 
3L, 2L, 3L, 1L, 1L), V7 = c("Detected Organism: Staphylococcus Aureus, Comment: Looks good", 
"Detected Organism: Staphylococcus Aureus, Comment: Looks good", 
"Detected Organism: Staphylococcus Aureus, Comment: Note 1", 
"Detected Organism: Staphylococcus Aureus, Comment: Note 1", 
"Detected Organism: Stenotrophomonas Maltophilia, Comment: new note", 
"Detected Organism: Human Adenovirus 7, Comment: test")), .Names = c("detected_id", 
"reviewer_name", "created_at", "stage", "V7"), row.names = c(NA, 
-6L), class = "data.frame")

*编辑:使用Matt的帮助更新