Biswajit wrote:Need to check for 6000 PC so want to aviod invoke-command 6000 time. Will try some foreach if we can define the source IP.
Well, good luck with that. If you want to actually check the connection from 6000 source endpoints, then you need to make the code execute on each of them in some way. In PowerShell, the preferred way of doing that is Invoke-Command. You can try some other method, but it will basically amount to the same idea of executing code on the remote computers.
Test-Connection, for example, appears to let you ping a computer from a remote source via its -Source parameter, but all it's doing is making a WMI call to that remote computer, and the WMI class then runs the ping. Different protocol, but in principle, the same idea as running Invoke-Command.
On a side note, you don't have to run Invoke-Command 6000 times. You can run it once, and pass it 6000 computer names or PSSession objects. That will offer you better performance anyway, as Invoke-Command will do some number of the connections in parallel (32 at a time, by default.)