Many times It happens that we need to check if a list of computers is active, so how do you ping multiple computers at once?
Use this Powershell script to test connectivity to your list of computers. it will produce two lists of Bad (unresponsive) and Good(Responsive) computers.
You need to change “D:\scripts\list.txt” to the path where your saved your computers list file(.txt).
Also, you can un-comment #Write-Host $name… to view the list of computers with different colors
$Mylist = Get-Content D:\scripts\list.txt #this is where you put your list of computers Clear-Host [System.Collections.ArrayList]$GoodArrayList = @() [System.Collections.ArrayList]$BadArrayList = @() foreach ($name in $Mylist){ if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){ #Write-Host $name -ForegroundColor Cyan $GoodArrayList.Add($name) } else{ #Write-Host $name "down" -ForegroundColor Red $BAdArrayList.Add($name) } } Write-Host -ForegroundColor Cyan "Good Computers :)" $GoodArrayList Write-Host -ForegroundColor Red "Bad Computers :(" $BadArrayList
I tried this script but it gave me the below error:
At line:22 char:2
+ [/powershell]
+ ~
Missing type name after ‘[‘.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingTypename
you have a typo: [/powershell]
you dont need to write [/powershell] in your script.