Check whether a Server is Up & Running

########################################
# Name: PingAtor
# Desc: Perform a quick Ping test for a group of servers.
# The Server list is stored on a text file.
# Date: 14/05/2011
# Auth: Alberto Ruiz
########################################

$ServerList=”.\servers.txt”
$Pingator = New-Object system.Net.NetworkInformation.Ping
$IpFile= Get-Content $ServerList
cls

ForEach($ServerIP in $IpFile) {

Try
{

If ($Pingator.Send($ServerIP).status -eq “Success”)

{Write-Host -Foreground White “$ServerIP ……..” -nonewline; write-host -ForegroundColor Green ” Alive” }

else

{Write-Host -Foreground White “$ServerIP ……..” -nonewline; write-host -ForegroundColor Red ” Dead”}

}
Catch {Write-Host -ForeGround White “$ServerIP …….” -nonewline; Write-Host -ForegroundColor Yellow ” Oops… Check DNS Resolution / Firewalls…”}

}

Advertisements

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