Skip to content

Instantly share code, notes, and snippets.

@marcorichetta
Created March 18, 2018 14:29
Show Gist options
  • Save marcorichetta/a43962fc41b67659c3da0201f4a50c02 to your computer and use it in GitHub Desktop.
Save marcorichetta/a43962fc41b67659c3da0201f4a50c02 to your computer and use it in GitHub Desktop.
Test IP connections from a csv file
$Devices = Import-Csv "Z:\Downloads\devices.txt"
# ComputerName,IP should be the first line (header) in CSV file.
foreach ($Device in $Devices)
{
if (Test-Connection -ComputerName $Device.IP -Count 1 -ErrorAction SilentlyContinue)
{
Write-Host "$($Device.ComputerName),up"
}
else
{
Write-Host "$($Device.ComputerName),down"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment