Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Ping HostNames from the csv file

$
0
0

$servers = Import-Csv c:\Source\ping.csv

#$servers = "test1", "test2", "test3"

$collection = $()

foreach ($server in $servers)

{

if (Test-Connection $server -Count 1 -ea 0 -Quiet)

{

Write-Host $server is UP

}

else

{

Write-Host $server is DOWN

}

}

when i run

$servers = "test1", "test2", "test3"

script works as expected, however when i am reading the csv file i am getting:

@{test1=test2} as the hostname. what am i missing? Thank you.


Viewing all articles
Browse latest Browse all 6937

Trending Articles