Q. How do I use Test-Connection in PowerShell?
A. This cmdlet basically uses WMI's Win32_PingStatus under the hood. It returns, by default, four "result" objects, each of which contains various properties, including a StatusCode, which will be 0 for successful pings. Sometimes, you just want to know if it worked or not, without all that extra information. In those cases, use:
And you'll get back a simple True or False, which can be used in an If construct:
Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.