(Powershell) Check if Hosts are Up

Posted by keith.wirch at October 15, 2013

Category: Powershell

Small one but a good one.  This script will ping all hosts in a text file to see if they are up.  It’s great in the of case you want to see all of the stations in a classroom before you push an update or something.

Here it is.

$names = Get-Content "C:\Scripts\Computers.txt"

foreach ($name in $names) {

if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) {

Write-Host "$name is up" -ForegroundColor Magenta


else {

Write-Host "$name is down" -ForegroundColor Red



Line 1 is where you designate your text file of computers.  From there you just execute the powershell script and it will run something like the output below.  I’d reccomend making a bunch of “computer” files for each room you will routinly check like this and then only changeing line 1 to match what you need.

Again, some areas are blurred to protect the innocent!  MSPaint for the win my friends!



Leave a comment

(required) (will not be published)