Monday, November 16, 2015

Script to check connectivity to a list of computers

$on = @()
$off = @()
Import-Csv $args[0] | ForEach {

    If (Test-Connection $_.ComputerName -Count 1 -Quiet) {

       $on += $($_.ComputerName)
       
    } else {
  $off += $($_.ComputerName)
 
    }
}

write-host "The Following Computers are Turned On"
$on | Out-String

write-host "The Following Computers are Turned Off"
$off | Out-String



CSV Example

ComputerName
pc1.domain.com
pc2.domain.com