{"id":1282,"date":"2011-03-24T13:22:01","date_gmt":"2011-03-24T04:22:01","guid":{"rendered":"http:\/\/livedevil.net\/?p=1282"},"modified":"2011-03-24T13:22:01","modified_gmt":"2011-03-24T04:22:01","slug":"powershell-ping-multipletarget","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=1282","title":{"rendered":"Powershell \u2013 Ping-MultipleTarget"},"content":{"rendered":"<p>ICMP \ud328\ud0b7\uc744 \uc774\uc6a9\ud558\uc5ec Ping \uacb0\uacfc\ub97c bool \ub85c \ub9ac\ud134\ud558\ub294 Function\uc744 \uc791\uc131\ud558\uace0, \uc774\ub97c \uc774\uc6a9\ud558\uc5ec \uc9c0\uc815\ub41c \ubc94\uc704 \uc758 \ubaa8\ub4e0 \uc8fc\uc18c\uc5d0 Ping\uc744 \uc2dc\ub3c4\ud558\uc5ec Host\ub4e4\uc758 \uc0c1\ud0dc\ub97c \ud655\uc778 \ud55c\ub2e4.<\/p>\n<pre class=\"lang:ps decode:true\">\nparam\n(\n\t[Parameter(Mandatory=$true)]\n\t$BaseIp,\n\t$Start = 1,\n\t$End = 255,\n\t$Timeout = 100\n)\n\nFunction Ping-Target\n{\n\tparam (\n\t\t[Parameter(Mandatory=$true)]\n\t\t[string]$HostNameOrAddress,\n\t\t[int]$Timeout = 100\n\t\t)\n\n\t$pingObject = New-Object System.Net.NetworkInformation.Ping\n\t$pingReply = $pingObject.Send($HostNameOrAddress, $Timeout)\n\n\treturn $pingReply.Status -eq [System.Net.NetworkInformation.IPStatus]::Success\n}\n\n$Start..$End | %{ $BaseIp + $_ } |\n\t%{\n\t\tif ($(Ping-Target $_ $Timeout))\n\t\t{\n\t\t\tWrite-Host $($_ + \" .. Success\") -ForegroundColor Green\n\t\t}\n\t\telse\n\t\t{\n\t\t\tWrite-Host $($_ + \" .. Fail\") -ForegroundColor Red\n\t\t}\n\t}\n<\/pre>\n<div id=\"attachment_1290\" style=\"width: 639px\" class=\"wp-caption alignnone\"><a href=\"wp-content\/uploads\/2011\/03\/Ping-MultipleTarget.png\"><img aria-describedby=\"caption-attachment-1290\" loading=\"lazy\" src=\"wp-content\/uploads\/2011\/03\/Ping-MultipleTarget.png\" alt=\"Ping-MultipleTarget\" title=\"Ping-MultipleTarget\" width=\"629\" height=\"378\" class=\"size-full wp-image-1290\" srcset=\"https:\/\/talsu.net\/wp-content\/uploads\/2011\/03\/Ping-MultipleTarget.png 629w, https:\/\/talsu.net\/wp-content\/uploads\/2011\/03\/Ping-MultipleTarget-300x180.png 300w\" sizes=\"(max-width: 629px) 100vw, 629px\" \/><\/a><p id=\"caption-attachment-1290\" class=\"wp-caption-text\">Ping-MultipleTarget Sample.<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>ICMP \ud328\ud0b7\uc744 \uc774\uc6a9\ud558\uc5ec Ping \uacb0\uacfc\ub97c bool \ub85c \ub9ac\ud134\ud558\ub294 Function\uc744 \uc791\uc131\ud558\uace0, \uc774\ub97c \uc774\uc6a9\ud558\uc5ec \uc9c0\uc815\ub41c \ubc94\uc704 \uc758 \ubaa8\ub4e0 \uc8fc\uc18c\uc5d0 Ping\uc744 \uc2dc\ub3c4\ud558\uc5ec Host\ub4e4\uc758 \uc0c1\ud0dc\ub97c \ud655\uc778 \ud55c\ub2e4. param ( [Parameter(Mandatory=$true)] $BaseIp, $Start = 1, $End = 255, $Timeout = 100 ) Function Ping-Target { param ( [Parameter(Mandatory=$true)] [string]$HostNameOrAddress, [int]$Timeout = 100 ) $pingObject = New-Object System.Net.NetworkInformation.Ping $pingReply = $pingObject.Send($HostNameOrAddress, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[25,26],"tags":[141,186,481,251],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-kG","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1282"}],"collection":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1282"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1282\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}