Jose Colmenares
asked on
How to check if 5000 computers are UP?
Hi all,
I need to know if 5000 computers on a list .csv are UP?
Which command can i use?
I have this but is for only one computer.
Test-Connection -BufferSize 32 -Count 1 -ComputerName 192.168.0.41 -Quiet
Can you help me?
I need to know if 5000 computers on a list .csv are UP?
Which command can i use?
I have this but is for only one computer.
Test-Connection -BufferSize 32 -Count 1 -ComputerName 192.168.0.41 -Quiet
Can you help me?
ASKER
In my .csv I only have the name of computers and the Header is ComputerName.
I don´t have the ip address.
I don´t have the ip address.
Review below link..Does not have exactly how to use the csv function but you may get workaround
https://www.petri.com/test-network-connectivity-powershell-test-connection-cmdlet
https://www.petri.com/test-network-connectivity-powershell-test-connection-cmdlet
refactored to comply with user response and added to a code block
<#
.SYNOPSIS
Powershell script to ping all IP addresseses in a CSV file.
.DESCRIPTION
This PowerShell script reads a CSV file and pings all the IP addresses listed in the IPAddress column.
.PARAMETER <csvfile>
File name and path of the CSV file to read.
.NOTES
Version:
1.0 Alessio Pe
1.01 David Johnson
.EXAMPLE
Ping-IPList c:\IPaddressList.csv
#>
Param(
[Parameter(Mandatory=$true, position=0)][string]$csvfile
)
Write-Host "Reading file" $csvfile
$ipaddresses = import-csv $csvfile
Write-Host "Started Pinging.."
foreach( $ip in $ipaddresses) {
$computer = $ip.computername
if (test-connection -ComputerName $computer -count 1 -quiet) {
write-host $computer "Ping succeeded." -foreground green
} else {
write-host $computer "Ping failed." -foreground red
}
}
Write-Host "Pinging Completed."
ASKER
Thanks u. It works. I need export a .csv with the 5000 results. How Can I do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, had to fix an error in line 62.
If you already tested the script before this comment (and wondered about the strange results), download it again, or change line 62 to this:
If you already tested the script before this comment (and wondered about the strange results), download it again, or change line 62 to this:
$rsJob = [powershell]::Create().AddScript($sbPing).AddArgument($_)
ASKER
I can´t execute it
the error is Script descriptions is disabled in this system
the error is Script descriptions is disabled in this system
In an elevated PS console, enter
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
ASKER
This command solved my necessity, Besides checking if my computers are active and turned on I get to know the ip address of each one.
.SYNOPSIS
Powershell script to ping all IP addresseses in a CSV file.
.DESCRIPTION
This PowerShell script reads a CSV file and pings all the IP addresses listed in the IPAddress column.
.PARAMETER <csvfile>
File name and path of the CSV file to read.
.NOTES
Version: 1.0
.EXAMPLE
Ping-IPList c:\IPaddressList.csv
#>
Param(
[Parameter(Mandatory=$true
)
$ColumnHeader = "IPaddress"
Write-Host "Reading file" $csvfile
$ipaddresses = import-csv $csvfile | select-object $ColumnHeader
Write-Host "Started Pinging.."
foreach( $ip in $ipaddresses) {
if (test-connection $ip.("IPAddress") -count 1 -quiet) {
write-host $ip.("IPAddress") "Ping succeeded." -foreground green
} else {
write-host $ip.("IPAddress") "Ping failed." -foreground red
}
}
Write-Host "Pinging Completed."