Hi,

 In Jan i upload the scipt to ping multiple servers using powershell {http://gallery.technet.microsoft.com/scriptcenter/Ping-Multiple-Servers-ba915a7c}.

yesterday i got an request from user, he want to email the Output of the script. to full fill his requirement I twaeked the script a little bit.

The best of this script that, you can add all of your server which you want to monitor in to the script and schedule the to run after 3-4 hours or run after every 12 hours. So it will send you the email and then you can know that which server is runiing which are not.

thanks

Best Regards!

Aman Dhally 

Come and join my journey of 100 Days of Self Improvement programme: https://www.facebook.com/100DoSI or at www.amandhally.net   

MY PowerShell Blog : http://newdelhipowershellusergroup.blogspot.com/ 

MY Personal Website: www.amandhally.net

 

 

PowerShell
Edit|Remove
#+-------------------------------------------------------------------+   
#| = : = : = : = : = : = : = : = : = : = : = : = : = : = : = : = : = |   
#|{>/-------------------------------------------------------------\<}|            
#|: | Author:  Aman Dhally                                        | :|            
#| :| Email:   amandhally@gmail.com 
#|: | Purpose: Ping Multiple Servers / Computers      
#|: |                    Date: 15-Nov-2011         
#| :|     /^(o.o)^\         Version: 1                                  |: |  
#|{>\-------------------------------------------------------------/<}| 
#| = : = : = : = : = : = : = : = : = : = : = : = : = : = : = : = : = | 
#+-------------------------------------------------------------------+ 
 
#blog: http://newdelhipowershellusergroup.blogspot.in/2011/11/hi-today-i-was-looking-for-little.html  
 
#### Provide the computer name in $computername variable 
 
$ServerName = "localhost","Dc-XX" 
 
 
 
$smtp = "ExchChange" 
$to = "amandhally@gmail.com" 
$from = "newdelhi@gmail.com" 
$sub = " Server Status" 
$body = @" 
"@ 
 
 
##### Script Starts Here ######  
 
 
 
 foreach ($Server in $ServerName) { 
                    if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
                        $body += write-output "$Server is alive and Pinging `n"  
 
                            } else { $body += Write-output "$Server seems dead not pinging `n"  
 
                            }     
         
} 
 
 
$body 
 
send-MailMessage -SmtpServer $smtp -To $to -Subject $sub -Body $body  -From $from   
 
 
########## end of script #######################