
{"id":1363,"date":"2015-04-27T22:43:05","date_gmt":"2015-04-27T22:43:05","guid":{"rendered":"http:\/\/tech-no.104.210.61.21.xip.io\/?p=1363"},"modified":"2015-04-27T22:43:05","modified_gmt":"2015-04-27T22:43:05","slug":"howto-ping-list-of-hosts-from-a-file-and-output-to-txt","status":"publish","type":"post","link":"https:\/\/tech-no.org\/?p=1363","title":{"rendered":"HOWTO: ping list of hosts from a file and output to txt"},"content":{"rendered":"<p>I used to do this with a batch file and for some reason it didnt work on Windows 7 SP1 today. So i asked a colleague for a powershell way to do this quickly. Props to Robert Ramsay over at NAMMCAL with the script.<\/p>\n<p>copy the following and save in the c:\\scripts folder as ping.ps1<\/p>\n<blockquote><p>$names = Get-Content &#8220;C:\\scripts\\list.txt&#8221;<br \/>\nforeach ($name in $names) {<br \/>\nif ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) {<br \/>\nWrite-Host &#8220;$name is up&#8221; -ForegroundColor Magenta<br \/>\n}<br \/>\nelse {<br \/>\nWrite-Host &#8220;$name is down&#8221; -ForegroundColor Red<br \/>\n}<br \/>\n}<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p>Next you will need to open a administrator elevated Powershell command prompt and set your execution level to unrestricted<\/p>\n<p>set-executionpolicy unrestricted<\/p>\n<p>Next in your powershell window you can change directory to c:\\scripts and type .\/ping.ps1 &gt; output.txt and it will save the output to the file. \u00a0DONE<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I used to do this with a batch file and for some reason it didnt work on Windows 7 SP1 today. So i asked a colleague for a powershell way to do this quickly. Props to Robert Ramsay over at NAMMCAL with the script. copy the following and save in the c:\\scripts folder as ping.ps1 &hellip;<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1363"}],"collection":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1363"}],"version-history":[{"count":1,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions"}],"predecessor-version":[{"id":1364,"href":"https:\/\/tech-no.org\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions\/1364"}],"wp:attachment":[{"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech-no.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}