![]() If test-connection ping status is true then print response on output as ‘computer name’ is online else ‘computer name is offline’ using Write-Host cmdlet.Ĭool Tip: Do you know how to print environment variables in PowerShell! ErrorAction Silentl圜ontinue parameter ensures that in case of host not responding, it should not throw any error and print output as the host machine is offline. Count 1 parameter with test-connection cmdlet ensure to ping host remote machine only once and get a response. ![]() ![]() Use test-connection cmdlet to send echo request or ping. Using Get-Content cmdlet, it reads txt file and stores list into $complist variable.Īs we have to ping list of remote computer, use ForEach loop to iterate over each computer name at a time. In the above PowerShell test connection script, we have a list of computers stored in a text file. $pingtest = Test-Connection -ComputerName $comp -Quiet -Count 1 -ErrorAction Silentl圜ontinue Use below PowerShell ping script to test connection status of list of computers $complist = Get-Content "D:\PowerShell\complist.txt" We have a requirement to ping a list of remote computers for their status and echo their response as output. Let’s consider an example, we have a txt file that contains a list of computers. Test-Connection to ping multiple computers PowerShell test-connection cmdlet sends ICMP echo requests packets or ping one or multiple remote machines and returns echo response replies.
0 Comments
Leave a Reply. |