3 users responded in this post

Subscribe to this post comment rss or trackback url
User Gravatar
danovich said in January 18th, 2011 at 3:04 pm

I’ve updated this script to provide 3 different responses – “Resolved & active”, “Resolved host but timed out” and “Unable to resolve”.

This is a great reference – http://blog.usepowershell.com/2009/02/exploring-the-net-framework-with-powershell-calling-a-method-part-2a/

New Powershell script is:

$erroractionpreference = “SilentlyContinue”
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = “Machine Name”
$c.Cells.Item(1,2) = “Ping Status”
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit($True)
$intRow = 2
$colComputers = get-content C:\temp\server_list.txt
foreach ($strComputer in $colComputers)
{
$c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
# This is the key part
$ping = new-object System.Net.NetworkInformation.Ping
$Reply = $ping.send($strComputer)
if ($Reply.status –eq “Success”)
{
$c.Cells.Item($intRow, 2) = “Resolved & active”
}
elseif ($Reply.status –eq “TimedOut”)
{
$c.Cells.Item($intRow, 2) = “Resolved host but timed out”
}
else
{
$c.Cells.Item($intRow, 2) = “Unable to resolve”
}
$Reply = “”
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()

VN:F [1.9.11_1134]
Rating: 5.0/5 (4 votes cast)
User Gravatar
mahesh said in January 31st, 2012 at 7:22 pm

Hi,
can u attach the smtp server script.so that Excel file will go to the reciepient

VA:F [1.9.11_1134]
Rating: 0.0/5 (0 votes cast)
User Gravatar
danovich said in February 3rd, 2012 at 12:45 pm

Hi Mahesh – That is pretty easy to do. If you require billable consulting, my details are available in the Contact page.

VN:F [1.9.11_1134]
Rating: 0.0/5 (0 votes cast)
Leave A Reply

 Username (Required)

 Email Address (Remains Private)

 Website (Optional)