Created
March 18, 2018 14:29
-
-
Save marcorichetta/a43962fc41b67659c3da0201f4a50c02 to your computer and use it in GitHub Desktop.
Test IP connections from a csv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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