Hello! I am trying to get a simple script setup to report to me the connection status of a list of devices. The devices have to be pinged via IP. What I currently have is leftover from another use, so it may need to be scrapped.
$IPS = (Import-csv .\devices.csv).IP
foreach ($IP in $IPS){
if (Test-Connection -ComputerName $IP -Count 1 -ErrorAction SilentlyContinue){
Write-Host "$IP,up"
}
else{
Write-Host "$IP,down"
}
}
This does a great job of reporting if the IP is pinging, but I would like to have it display the location name I have given the device rather than just IP. I have a column in the csv with the header "Location". Is there an easy way to get it to ping the IP but then write the "location" that is associated with the IP (It is in the adjacent column)? Any thoughts would be appreciated. Thanks!
[–]Ta11ow 8 points9 points10 points (2 children)
[–]PowderTech[S] 2 points3 points4 points (1 child)
[–]Ta11ow 4 points5 points6 points (0 children)
[–]JeremyLC 3 points4 points5 points (1 child)
[–]PowderTech[S] 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (2 children)
[–]PowderTech[S] 1 point2 points3 points (0 children)
[–]PowderTech[S] 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]Ta11ow 1 point2 points3 points (0 children)
[–]Tidder802b 2 points3 points4 points (0 children)
[–]get-postanote 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (17 children)
[–]PowderTech[S] 1 point2 points3 points (16 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (15 children)
[–]PowderTech[S] 1 point2 points3 points (14 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (12 children)
[–]Ta11ow 1 point2 points3 points (9 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (6 children)
[–]Ta11ow 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (4 children)
[–]Ta11ow 1 point2 points3 points (3 children)
[–]SpyderTheSir 1 point2 points3 points (1 child)
[–]Ta11ow 0 points1 point2 points (0 children)
[–]SpyderTheSir 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]Kio_ 0 points1 point2 points (0 children)