Always A-HEAD, By being ahead you are always master of time

Hits

BOOKS

Monday, 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: ,

1 comment:

James said...

Hi, thanks for this post.

See also Bulk Ping

James