Posted by: Preetam | December 25, 2006

Bulk Ping Via PowerShell

CODE:

$readfile=get-content “E:\PowerShell\MakesSense\Servers.txt”
foreach($readf in $readfile)
{
$ALive=get-wmiobject win32_pingstatus -Filter “Address=’$readf'” | Select-Object statuscode

if($ALive.statuscode -eq 0)
{write-host $readf is REACHABLE -background “GREEN” -foreground “BLACk”}
else
{write-host $readf is NOT reachable -background “RED” -foreground “BLACk”}
}

OUTPUT:

I was reviewing my codes and I realise it would only start making difference only when I show the output. Also most of the codes in previous post might not work, because of formatting. But I want to know which are not actually working. Please let me know if you come across something like this.

Remember to create servers.txt file and put in all servers in txt file which you which to ping.

Apart from this, I’m getting question in similiar nature what can you do with powershell. Yes that is very simple to answer and believe it, if you go to the MS Site mentioned below.

Worth Visiting collection of Powershell Scripts, you are bound to love it.

What Can I Do With Windows PowerShell?

Flickr tags: ,

Technorati tags: ,

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

Categories

%d bloggers like this: