Powershell – Ping servers using wmi class svr-ping.ps1

After a long time this is one new post from me… 😉 !!!!
 
Here is one more PowerShell script which uses WMI class PingStatus to check if server is reachable or not remotely 

The computer/server name should be mentioned in “Computers.txt” file

The script can use both IP address or hostname to check the ping status remotely

Ofcourse there are many other ways to ping servers however this is the easiest way I found to be quick way to check the server ping status remotely


Content of svr-ping.ps1

————————————————————————————
foreach ($computers in Get-Content “Computers.txt”)
{

$Computer = Get-WmiObject Win32_PingStatus -f “Address=’$computers'”

if($computer.StatusCode -eq 0) 
{
“{0,0} {1,5} {2,5}” -f$computer.Address, $computer.StatusCode, “Its pinging”
}
else
{
“{0,0} {1,5} {2,5}” -f $computer.Address, $computer.StatusCode, “Its not reachable”

}

————————————————————————————

Advertisements

About asifkhandevadi

Hello, I have been working on windows since 9 years and currently working as windows, VMware and MS clustering SME at IBM. Whenever I get free time I participate in Microsoft forums and write some blogs to enhance my technical and communication skills through knowledge sharing. Please contact me on FB or Linkedin if you need any assistance on troubleshooting, implementation and virtualizaton.
This entry was posted in Power-Shell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s