{"id":1029,"date":"2010-06-27T19:23:18","date_gmt":"2010-06-27T10:23:18","guid":{"rendered":"http:\/\/livedevil.net\/?p=1029"},"modified":"2010-06-27T19:23:18","modified_gmt":"2010-06-27T10:23:18","slug":"powershell-test-connection-%ec%9c%bc%eb%a1%9c-%eb%84%a4%ed%8a%b8%ec%9b%8c%ed%81%ac%ec%83%81%ec%9d%98-host%eb%93%a4-%ed%99%95%ec%9d%b8%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=1029","title":{"rendered":"Powershell Test-Connection \uc73c\ub85c \ub124\ud2b8\uc6cc\ud06c\uc0c1\uc758 Host\ub4e4 \ud655\uc778\ud558\uae30"},"content":{"rendered":"<p>Powershell cmdlet \uc911 \ud558\ub098\uc778 Test-Connection \uc740 \ub124\ud2b8\uc6cc\ud06c\uc0c1\uc758 Host\uc640 ICMP \ud328\ud0b7\uc744 \uc774\uc6a9\ud558\uc5ec \uc5f0\uacb0\uc744 \ud14c\uc2a4\ud2b8 \ud560 \uc218 \uc788\ub2e4. \uc774 cmdlet\uc740 \ud754\ud788 cmd \uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 ping.exe\uc640 \ub9e4\uc6b0 \uc720\uc0ac\ud558\ub2e4.<\/p>\n<pre class=\"lang:default nums:false wrap:false decode:true\">\nTest-Connection [-ComputerName] <string[]> [[-Source] <string[]>] [-AsJob] [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-BufferSize <int>] [-Count <int>] [-Credential <pscredential>] [-Delay <int>] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Quiet] [-ThrottleLimit <int>] [-TimeToLive <int>] [<commonParameters>]\n<\/pre>\n<p>ping.exe \ub85c \ud560 \uc218 \uc788\ub294 \uac83\uc740 \uac70\uc758 \ub2e4 \ud560 \uc218\uc788\uace0, Powershell Cmdlet\uc778 \ub9cc\ud07c \ub2e4\ub978 cmdlet\uacfc \uc870\ud569\ud574 \uc4f0\uba74 \ub354\uc6b1 \uc720\uc6a9\ud560 \uac83\uc774\ub2e4.<\/p>\n<p>\uac04\ub2e8\ud55c \uac83\ubd80\ud130 \uc2dc\uc791 \ud574 \ubcf4\uc790.<br \/>\nIP\uac00 192.168.0.10\uc778 Host \ub85c Test-Connection \ud55c\ub2e4.<\/p>\n<pre class=\"lang:ps nums:false wrap:true decode:true\">\nTest-Connection 192.168.0.10\t# Test-Connection -ComputerName 192.168.0.10\n<\/pre>\n<p>\uc131\uacf5\uc801\uc774\ub77c\uba74 \ub2e4\uc74c\uacfc \uac19\uc740 \uacb0\uacfc\ub97c \ubcfc \uac83\uc774\ub2e4.<\/p>\n<pre class=\"lang:default nums:false wrap:false decode:true\">\nSource   Destination  IPV4Address  IPV6Address                  Bytes Time(ms)\n------   -----------  -----------  -----------                  ----- --------\nTALSU-PC 192.168.0.20 192.168.0.20 fe80::3d95:e8c9:298f:33dc%13 32    0\nTALSU-PC 192.168.0.20 192.168.0.20 fe80::3d95:e8c9:298f:33dc%13 32    0\nTALSU-PC 192.168.0.20 192.168.0.20 fe80::3d95:e8c9:298f:33dc%13 32    0\nTALSU-PC 192.168.0.20 192.168.0.20 fe80::3d95:e8c9:298f:33dc%13 32    0\n<\/pre>\n<p>\uc131\uacf5\uc801\uc73c\ub85c ICMP \ud328\ud0b7\uc744 \ubcf4\ub0b4\uace0 \uc751\ub2f5\uc744 \ubc1b\uc740 \ubaa8\uc2b5\uc774\ub2e4. (\uc790\uc2e0\uc758 IP\ub85c \ud558\uba74 100% \uc131\uacf5\ud560 \uc218 \uc788\ub2e4.)<\/p>\n<p>\uc2e4\ud328\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc740 Error \uac00 \ubc1c\uc0dd \ud55c\ub2e4.<\/p>\n<blockquote><p><span style=\"color: #ff0000;\">Test-Connection : &#8216;192.168.0.10&#8217; \ucef4\ud4e8\ud130\uc5d0 \ub300\ud55c \uc5f0\uacb0 \ud14c\uc2a4\ud2b8\uac00 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4. \ub370\uc774\ud130\ubca0\uc774\uc2a4\ub97c \uac80\uc0c9\ud558\ub294 \ub3d9\uc548 \ubcf5\uad6c\ud560 \uc218 \uc5c6\ub294 \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\uc2b5\ub2c8\ub2e4<br \/>\n\uc704\uce58 \uc904:1 \ubb38\uc790:16<br \/>\n+ Test-Connection <<<<  192.168.0.10 | clip\n    + CategoryInfo          : ResourceUnavailable: (192.168.0.10:String) [Test-Connection], PingException\n    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand\n<\/span><\/p><\/blockquote>\n<p>ICMP \ud328\ud0b7\uc744 \ubcf4\ub0b4\uace0 \uc751\ub2f5\uc774 \uc5c6\uc744\ub54c\ub9c8\ub2e4. \uac19\uc740 \uc5d0\ub7ec\uac00 \uacc4\uc18d \ubc1c\uc0dd \ud55c\ub2e4.<\/p>\n<p>Error\uac00 \ubcf4\uace0 \uc2f6\uc9c0 \uc54a\uace0 \uc811\uc18d \uacb0\uacfc\ub9cc \uc5bb\uae30 \uc704\ud574\uc11c\ub294 -Quiet Parameter\ub97c \uc0ac\uc6a9\uba74 \uadf8 \uacb0\uacfc\uc5d0 \ub530\ub77c $true, $false (Bool)\ub97c \ubc18\ud658 \ud55c\ub2e4.<\/p>\n<pre class=\"lang:ps nums:false wrap:true decode:true\">\nTest-Connection 192.168.0.10 -Quiet\t\t# Error \uc5c6\uc774 [bool] \ud0c0\uc785\uc744 \ubc18\ud658\ud55c\ub2e4.\n<\/pre>\n<p>\uc774\ubc88\uc5d0\ub294 \ud55c\ubc88\uc5d0 \uac19\uc740 Class\uc5d0 \uc788\ub294 Host \ub4e4\uc5d0\uac8c \ubaa8\ub450 Test-Connection\uc744 \uc2dc\ub3c4\ud574 \ubcf4\uc790.<\/p>\n<pre class=\"lang:ps nums:false wrap:true decode:true\">\n1..255 | Foreach-Object { Test-Connection \"192.168.0.$_\" }\n<\/pre>\n<p>192.168.0.1 ~ 192.168.0.255 \uae4c\uc9c0 \ubaa8\ub450 Test-Connection\uc744 \uc2dc\ub3c4 \ud558\uba74\uc11c \uacb0\uacfc\ub97c \ubcf4\uc77c \uac83\uc774\ub2e4. \uadf8\ub7f0\ub370 ICMP\ud328\ud0b7\uc744 4\ubc88\uc529 \ubcf4\ub0b4\uace0 \uc751\ub2f5\uc774 \uc5c6\ub294 Host\uc5d0\ub294 Error \uba54\uc138\uc9c0\uac00 4\ubc88\uc529 \ub098\uc624\uae30 \ub54c\ubb38\uc5d0 \ubcf4\uae30\ub3c4 \uc27d\uc9c0 \uc54a\uace0 \ucd9c\ub825\uc744 \ub2e4\ub978\uacf3\uc5d0 \ud65c\uc6a9\ud558\uae30\ub3c4 \ubd88\ud3b8\ud574 \ubcf4\uc778\ub2e4.<\/p>\n<p>ICMP \ud328\ud0b7\uc744 \ud558\ub098\ub9cc \ubcf4\ub0b4\uace0 \uacb0\uacfc\ub294 Bool \ud0c0\uc785\uc73c\ub85c \ubc1b\uc544 \uc751\ub2f5\ud558\ub294 Host \ubc88\ud638\ub9cc \ubcf4\uba74 \uc88b\uc744 \uac83 \uac19\ub2e4.<\/p>\n<pre class=\"lang:ps nums:false wrap:true decode:true\">\n1..255 | Where-Object { Test-Connection \"192.168.0.$_\" -Count 1 -Quiet }\n<\/pre>\n<p>\uc608\uc0c1\ub300\ub85c \ub3d9\uc791\ud55c\ub2e4.<\/p>\n<p>\ubcf4\uae30 \uc88b\uac8c \ucd9c\ub825 \ub418\ub3c4\ub85d \uc870\uae08\ub354 \uc190\ubd10\uc11c \uc2a4\ud06c\ub9bd\ud2b8\ub85c \ub9cc\ub4e4\uc5b4\ub450\uba74 \ud3b8\ub9ac \ud558\ub2e4.<\/p>\n<h2>Test-MultipleConnections1.ps1<\/h2>\n<pre class=\"lang:ps wrap:false decode:true\">\nparam (\n\t[string]$Gateway,\n\t[int]$StartPosition = 1,\n\t[int]$EndPosition = 255\n\t)\n\nif ($Gateway -match \"(d{1,3}.){2}d{1,3}\")\n{\n\t$StartPosition..$EndPosition |\n\tForeach-Object {\n\t\t$Name = \"{0}.{1}\" -f $Matches[0], $_\n\n\t\tif (Test-Connection $Name -count 1 -quiet)\n\t\t{\n\t\t\t$Color = \"Green\"\n\t\t\t$Name += \" - Success\"\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$Color = \"Red\"\n\t\t\t$Name += \" - Fail\"\n\t\t}\n\n\t\tWrite-host $Name -ForegroundColor $Color\n\t}\n}\n<\/pre>\n<p><img src=\"wp-content\/uploads\/2010\/06\/Test-MultipleConnections1.png\" alt=\"Test-MultipleConnections1.ps1\" \/><\/p>\n<p>\uceec\ub7ec\ud480 \ud558\uace0 \ubcf4\uae30 \uc88b\uac8c \ub098\uc628\ub2e4. \ud558\uc9c0\ub9cc  PSObject \ucd9c\ub825\uc774 \ud544\uc694 \ud560 \ub54c\ub3c4 \uc788\ub2e4.<br \/>\n<\/br><\/p>\n<h2>Test-MultipleConnections2.ps1<\/h2>\n<pre class=\"lang:ps decode:true\">\nparam (\n    [string]$Gateway,\n    [int]$StartPosition = 1,\n    [int]$EndPosition = 255\n    )\n\nif ($Gateway -match \"(d{1,3}.){2}d{1,3}\")\n{\n\t$ResultObject = New-Object -TypeName PSObject\n\tAdd-Member -InputObject $ResultObject -MemberType NoteProperty -Name Address -Value $null\n\tAdd-Member -InputObject $ResultObject -MemberType NoteProperty -Name IsSuccess -Value $false\n\n    $StartPosition..$EndPosition |\n    Foreach-Object {\n        $ResultObject.Address = \"{0}.{1}\" -f $Matches[0], $_\n\n\t\t$ResultObject.IsSuccess = Test-Connection $ResultObject.Address -count 1 -quiet\n\n\t\t$ResultObject\n    }\n}\n<\/pre>\n<p><img src=\"wp-content\/uploads\/2010\/06\/Test-MultipleConnections2.png\" alt=\"Test-MultipleConnections2.ps1\" \/><\/p>\n<p><\/br><br \/>\nAdd-Member\uac00 \ubd80\ub2f4\ub418\uace0 \uc880\ub354 \uc27d\uac8c \uac00\ub824\uba74<\/p>\n<h2>Test-MultipleConnections3.ps1<\/h2>\n<pre class=\"lang:ps decode:true\">\nparam (\n    [string]$Gateway,\n    [int]$StartPosition = 1,\n    [int]$EndPosition = 255\n    )\n\nif ($Gateway -match \"(d{1,3}.){2}d{1,3}\")\n{\n    $StartPosition..$EndPosition |\n    Foreach-Object {\n\t\t$ResultHash = @{}\n        $ResultHash.Address = \"{0}.{1}\" -f $Matches[0], $_\n\t\t$ResultHash.IsSuccess = Test-Connection $ResultHash.Address -count 1 -quiet\n\n\t\tNew-Object PSObject -Property $ResultHash\n    }\n}\n<\/pre>\n<p>\ucd9c\ub825\uc740 Test-MultipleConnections2.ps1 \uc640 \uc720\uc0ac\ud558\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Powershell cmdlet \uc911 \ud558\ub098\uc778 Test-Connection \uc740 \ub124\ud2b8\uc6cc\ud06c\uc0c1\uc758 Host\uc640 ICMP \ud328\ud0b7\uc744 \uc774\uc6a9\ud558\uc5ec \uc5f0\uacb0\uc744 \ud14c\uc2a4\ud2b8 \ud560 \uc218 \uc788\ub2e4. \uc774 cmdlet\uc740 \ud754\ud788 cmd \uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 ping.exe\uc640 \ub9e4\uc6b0 \uc720\uc0ac\ud558\ub2e4. Test-Connection [-ComputerName] [[-Source] ] [-AsJob] [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-BufferSize ] [-Count ] [-Credential ] [-Delay ] [-Impersonation [&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":[26],"tags":[118,119,141,186,481,197,257,286,293],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-gB","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1029"}],"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=1029"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1029\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}