{"id":3830,"date":"2014-04-25T11:37:32","date_gmt":"2014-04-25T15:37:32","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3830"},"modified":"2014-04-25T11:37:32","modified_gmt":"2014-04-25T15:37:32","slug":"test-subnet-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/","title":{"rendered":"Test Subnet with PowerShell"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze-150x150.png\" alt=\"keyboardanalyze\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-2436\" \/><\/a>A few years ago I published a PowerShell function to <a href=\"http:\/\/jdhitsolutions.com\/blog\/2011\/11\/ping-ip-range\/\" title=\"read the original post\" target=\"_blank\">test IP addresses on a given subnet<\/a>. I had an email the other day about it and I decided to refresh it. My new version adds a few bells and whistles that I think you might like. For example, you can now run it from a remote computer. In other words, you can ping IP addresses from another computer which might be helpful.<\/p>\n<p>I've also added an option to resolve the IP address to a hostname using DNS. Because I don't want to require anything on a remote computer, I am using the .NET DNS class to resolve the name. In addition, I have included a fallback resolution using NETBIOS. If you ask for resolution, and DNS doesn't return a name, you can opt to use the NBTSTAT command to resolve the hostname. I use a regular expression pattern to pull the computername.<\/p>\n<p>Here's version 2.0 of Test-Subnet.<\/p>\n<pre class=\"lang:ps decode:true \" >\r\n#requires -version 3.0\r\n\r\nFunction Test-Subnet {\r\n\r\n&lt;#\r\n.SYNOPSIS\r\nPing addresses in an IP subnet\r\n.DESCRIPTION\r\nThis command is a wrapper for Test-Connection. It will ping an IP subnet range\r\nand return a custom object for each address indicating if the address responded\r\nto a ping.\r\n\r\nIPAddress      : 172.16.10.1\r\nHostname       : \r\nPinged         : True\r\nTTL            : 80\r\nBuffersize     : 32\r\nDelay          : 1\r\nTestDate       : 4\/25\/2014 9:53:08 AM\r\nPSComputerName : JH-WIN81-ENT\r\nRunspaceId     : ac86e6eb-676f-4e80-b231-4b554e2e5039\r\n\r\nBy default the command pings all hosts from 1 to 254 on the specfied subnet. \r\nEnter the subnet value like this: 172.16.10.0.\r\n\r\nYou can optionally choose to resolve the IP address to a hostname using DNS\r\nwith a last resort, if that fails, to use NETBIOS.\r\n\r\n.PARAMETER Subnet\r\nThe IP subnet such as 192.168.10.0. A regular expression pattern will validate\r\nthe subnet value.\r\n.PARAMETER Range\r\nThe range of host IP addresses. The default is 1..254.\r\n.PARAMETER Count\r\nThe number of pings to send. The default is 1. The most\r\nyou can send with this command is 10.\r\n.PARAMETER Delay\r\nThe delay between pings in seconds. The default is 1. The maximum value is 60.\r\n.PARAMETER Buffer\r\nSpecifies the size, in bytes, of the buffer sent with this command.\r\nThe buffer default is 32.\r\n.PARAMETER TTL\r\nSpecifies the maximum time, in seconds, that each echo request packet \r\n(\"pings\") is active. The default value is 80 (seconds). \r\n.PARAMETER AsJob\r\nRun the command as a background job.\r\n.PARAMETER Resolve\r\nResolve the DNS host name if the computer can be pinged.\r\n.PARAMETER UseNBT\r\nIf the host name cannot be resolved using DNS, attempt to resolve using NETBIOS\r\nand the NBTSTAT command.\r\n.PARAMETER Computername\r\nTest the subnet from a remote computer. The default is the local host.\r\nThe remote computer should be running PowerShell v3 or later but it is not\r\nrequired as long as remoting is enabled.\r\n.EXAMPLE\r\nPS C:\\&gt; Test-Subnet 192.168.10.0\r\nPing all computers in the 192.168.10 subnet.\r\n.EXAMPLE\r\nPS C:\\&gt; Test-Subnet 192.168.10.0 (100..200) -asjob\r\nPing computers 192.168.10.100 through 192.168.10.200 and run the command as a \r\nbackground job.\r\n.NOTES\r\nNAME        :  Test-Subnet\r\nVERSION     :  2.0   \r\nLAST UPDATED:  4\/25\/2014\r\nAUTHOR      :  Jeffery Hicks\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide (http:\/\/www.manning.com\/jones2\/)\r\n PowerShell Deep Dives (http:\/\/manning.com\/hicks\/)\r\n Learn PowerShell 3 in a Month of Lunches (http:\/\/manning.com\/jones3\/)\r\n Learn PowerShell Toolmaking in a Month of Lunches (http:\/\/manning.com\/jones4\/)\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n\r\nOriginally published http:\/\/jdhitsolutions.com\/blog\/2011\/11\/ping-ip-range\/\r\n\r\n.LINK\r\nhttp:\/\/jdhitsolutions.com\/blog\/2014\/04\/test-subnet-with-powershell\/\r\n.LINK\r\nTest-Connection \r\n.INPUTS\r\nNone\r\n.OUTPUTS\r\nCustom object\r\n#&gt;\r\n\r\n[cmdletbinding(DefaultParameterSetName=\"NoResolve\")]\r\n\r\nParam (\r\n[Parameter(Position=0)]\r\n[ValidatePattern(\"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.0\")]\r\n[string]$Subnet=\"172.16.10.0\",\r\n[Parameter(Position=1)]\r\n[ValidateRange(1,254)]\r\n[int[]]$Range=1..254,\r\n[ValidateRange(1,10)]\r\n[int]$Count=1,\r\n[ValidateRange(1,60)]\r\n[int]$Delay=1,\r\n[ValidateScript({$_ -ge 1})]\r\n[int]$Buffer=32,\r\n[ValidateScript({$_ -ge 1})]\r\n[int]$TTL=80,\r\n[Switch]$AsJob,\r\n[Parameter(ParameterSetName=\"Resolve\")]\r\n[Switch]$Resolve,\r\n[Parameter(ParameterSetName=\"Resolve\")]\r\n[Switch]$UseNBT,\r\n[ValidateNotNullorEmpty()]\r\n[string[]]$Computername=$env:COMPUTERNAME\r\n)\r\n\r\nWrite-Verbose \"Testing $subnet\"\r\n#define a scriptblock so we can run as a job if necessary\r\n$sb={\r\n\r\n#define some variables for Write-Progress\r\n$progHash=@{\r\nActivity = \"Test Subnet from $($env:computername)\"\r\nStatus = \"Pinging\"\r\nCurrentOperation = $Null\r\nPercentComplete = 0\r\n}\r\n\r\nWrite-Progress @progHash\r\n\r\n$i=0\r\n$total = ($using:Range).count\r\n\r\nForeach($node in ($using:range)) {\r\n\r\n    $i++\r\n    \r\n    $progHash.PercentComplete = ($i\/$total) * 100\r\n\r\n    #replace the 0 with the range number\r\n    $target= ([regex]\"0$\").replace($using:subnet,$node)\r\n\r\n    $progHash.CurrentOperation = $target\r\n    Write-Progress @progHash\r\n    \r\n    #define a hashtable of paramters to splat to Test-Connection\r\n    $pingHash = @{\r\n      ComputerName = $target\r\n      count = $using:count\r\n      Delay = $using:delay\r\n      BufferSize = $using:Buffer\r\n      TimeToLive = $using:ttl\r\n      Quiet = $True\r\n    }\r\n\r\n    $ping = Test-Connection @pingHash \r\n    \r\n    if ($ping -AND $using:resolve) {\r\n        $progHash.status =  \"Resolving host name\"\r\n        Write-Progress @progHash\r\n        &lt;#\r\n        using .NET because there's no guarantee remote computers\r\n        will have the necessary cmdlets, and this should also be\r\n        faster.\r\n        #&gt;\r\n        $Hostname = [system.net.dns]::Resolve(\"$target\").hostname\r\n\r\n        if ($UseNBT -AND ($hostname -eq $target)) {\r\n            Write-verbose \"Resolving with NBTSTAT\"\r\n            [regex]$rx=\"(?&lt;Name&gt;\\S+)\\s+&lt;00&gt;\\s+UNIQUE\"                                                              \r\n            $nbt = nbtstat -A $target | out-string\r\n            $Hostname = $rx.Match($nbt).groups[\"Name\"].value    \r\n\r\n        }\r\n    }\r\n    else {\r\n        $Hostname = $Null\r\n    }\r\n\r\n    #use an ordered hashtable if running v3 or later\r\n    if ($PSVersionTable.PSVersion.Major -ge 3) {\r\n        $resultHash = [ordered]@{\r\n            IPAddress = $Target\r\n            Hostname = $Hostname\r\n            Pinged = $ping\r\n            TTL = $using:TTL\r\n            Buffersize = $using:buffer\r\n            Delay = $Using:Delay\r\n            TestDate = Get-Date\r\n        }\r\n    }\r\n    else {\r\n       $resultHash = @{\r\n            IPAddress = $Target\r\n            Hostname = $Hostname\r\n            Pinged = $ping\r\n            TTL = $using:TTL\r\n            Buffersize = $using:buffer\r\n            Delay = $Using:Delay\r\n            TestDate = Get-Date\r\n        }\r\n    }\r\n\r\n    #create the property\r\n    New-Object -TypeName PSObject -Property $resultHash\r\n}\r\n} #close scriptblock\r\n\r\n\r\n#hashtable of parameters for Invoke-Command\r\n$icmHash = @{\r\n  Scriptblock = $sb\r\n  Computername = $Computername\r\n}\r\nif ($AsJob) {\r\n    Write-Verbose \"Creating a background job\"\r\n    #Start-Job -ScriptBlock $sb -Name \"Ping $subnet\" \r\n    $icmHash.Add(\"AsJob\",$True)\r\n    $icmHash.Add(\"JobName\",\"Ping $subnet\") \r\n}\r\n Write-Verbose \"Running the command\"\r\n Invoke-Command @icmHash \r\n \r\n} #end function\r\n<\/pre>\n<p>And to be clear, \"subnet\" may be a bit of a misnomer as I'm not calculating any addresses with a subnet mask. Instead you enter the base IPAddress, like 10.10.1.0 and then a range of host numbers between 1 and 254, which is the default by the way. The command will then test 10.10.1.1 through 10.10.1.254, or whatever you entered.<\/p>\n<p>My script employs some other techniques you might find help such as splatting, parameter sets, Write-Progress and parameter validation.  Here's a screenshot of results that I've sent to Out-Gridview and then customized.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/test-subnet.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/test-subnet-300x225.png\" alt=\"test-subnet\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-3831\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/test-subnet-300x225.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/test-subnet.png 679w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>But since the command writes objects to the pipeline you could do whatever you wanted. I trust you'll let me know what you think.  Enjoy!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few years ago I published a PowerShell function to test IP addresses on a given subnet. I had an email the other day about it and I decided to refresh it. My new version adds a few bells and whistles that I think you might like. For example, you can now run it from&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Fresh Friday Blog: Test Subnet Addresses with #PowerShell  http:\/\/wp.me\/p1nF6U-ZM","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,359,8],"tags":[534,540,174],"class_list":["post-3830","post","type-post","status-publish","format-standard","hentry","category-powershell","category-powershell-3-0","category-scripting","tag-powershell","tag-scripting","tag-test-connection"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Test Subnet with PowerShell  &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Test Subnet with PowerShell  &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"A few years ago I published a PowerShell function to test IP addresses on a given subnet. I had an email the other day about it and I decided to refresh it. My new version adds a few bells and whistles that I think you might like. For example, you can now run it from...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-25T15:37:32+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze-150x150.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Test Subnet with PowerShell\",\"datePublished\":\"2014-04-25T15:37:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/\"},\"wordCount\":281,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/keyboardanalyze-150x150.png\",\"keywords\":[\"PowerShell\",\"Scripting\",\"Test-Connection\"],\"articleSection\":[\"PowerShell\",\"Powershell 3.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/\",\"name\":\"Test Subnet with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/keyboardanalyze-150x150.png\",\"datePublished\":\"2014-04-25T15:37:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/keyboardanalyze.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/07\\\/keyboardanalyze.png\",\"width\":\"643\",\"height\":\"458\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3830\\\/test-subnet-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Test Subnet with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Test Subnet with PowerShell  &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Test Subnet with PowerShell  &#8226; The Lonely Administrator","og_description":"A few years ago I published a PowerShell function to test IP addresses on a given subnet. I had an email the other day about it and I decided to refresh it. My new version adds a few bells and whistles that I think you might like. For example, you can now run it from...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-04-25T15:37:32+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze-150x150.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Test Subnet with PowerShell","datePublished":"2014-04-25T15:37:32+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/"},"wordCount":281,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze-150x150.png","keywords":["PowerShell","Scripting","Test-Connection"],"articleSection":["PowerShell","Powershell 3.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/","name":"Test Subnet with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze-150x150.png","datePublished":"2014-04-25T15:37:32+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/keyboardanalyze.png","width":"643","height":"458"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3830\/test-subnet-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Test Subnet with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1855,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1855\/test-subnet-winform\/","url_meta":{"origin":3830,"position":0},"title":"Test-Subnet WinForm","author":"Jeffery Hicks","date":"November 21, 2011","format":false,"excerpt":"Recently, I posted an entry on how to ping an IP subnet with PowerShell. Using objects in the PowerShell pipeline is a good thing. But sometimes we want a GUI and I figured the ping subnet script would make a good WinForm script. When creating graphical PowerShell scripts, I always\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/11\/subnetpingform-300x178.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":754,"url":"https:\/\/jdhitsolutions.com\/blog\/commandline\/754\/get-your-tcp-ports-here\/","url_meta":{"origin":3830,"position":1},"title":"Get Your TCP Ports Here!","author":"Jeffery Hicks","date":"July 29, 2010","format":false,"excerpt":"Once again, the PowerShell forum at ScriptingAnswers.com has undone me. I was answering a question about running Netstat in a PowerShell session on a remote computer which got me thinking about a PowerShell function to turn NETSTAT.EXE output into objects. Once you have an object then you can do all\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/07\/get-tcp-300x171.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5864,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5864\/a-powershell-dns-suffix-tool\/","url_meta":{"origin":3830,"position":2},"title":"A PowerShell DNS Suffix Tool","author":"Jeffery Hicks","date":"February 1, 2018","format":false,"excerpt":"The other day my good friend Greg Shields asked for a little assistance with a PowerShell problem. He was trying to use PowerShell to set the primary DNS suffix for a computer. This\u00a0 is different than the DNS suffix you can set on a network adapter configuration. Instead, he was\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/system1_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1738,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1738\/ping-ip-range\/","url_meta":{"origin":3830,"position":3},"title":"Ping IP Range","author":"Jeffery Hicks","date":"November 7, 2011","format":false,"excerpt":"Last week I came across a post on using PowerShell, or more specifically a .NET Framework class, to ping a range of computers in an IP subnet. The original post by Thomas Maurer is here. I added a comment. And after looking at this again I decided to take the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2206,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2206\/powershell-scripting-with-validateset\/","url_meta":{"origin":3830,"position":4},"title":"PowerShell Scripting with [ValidateSet]","author":"Jeffery Hicks","date":"April 16, 2012","format":false,"excerpt":"Today we'll continue our exploration of the parameter validation attributes you can use in you PowerShell scripting. We've already looked at [ValidateRange] and [ValidateScript]. Another attribute you are likely to use is [ValidateSet()]. You can use this to verify that the parameter value belongs to a pre-defined set. To use,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5275,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5275\/managing-lmhosts-with-powershell\/","url_meta":{"origin":3830,"position":5},"title":"Managing LMHosts with PowerShell","author":"Jeffery Hicks","date":"October 6, 2016","format":false,"excerpt":"I've been in IT for a long time. It has been exciting to see how the industry has changed and how it as adapted to new technologies. Even so, I appreciate situations where sometimes the \"old ways\" are still the best ways. For example, we no longer really need the\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/10\/image_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/10\/image_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/10\/image_thumb.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=3830"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3830\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}