Hi ,
I have got this script need to add some thing more. Any way possible i can get ipv4 IP Address and in adittion i need configured dns as well on network card. So basically i need script who can read list from text file and check ping, write ip address , configured dns server , rdp port
$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"
$c.Cells.Item(1,3) = "IP Address"
$c.Cells.Item(1,4) = "Port 3389"
$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:Tempmachinelist.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"
$c.Cells.Item($intRow, 3) = $Reply.Address.ToString()
}
elseif ($Reply.status -eq "TimedOut")
{
$c.Cells.Item($intRow, 2) = "Resolved host but timed out"
$c.Cells.Item($intRow, 3) = $Reply.Address.ToString()
}
else
{
$c.Cells.Item($intRow, 2) = "Unable to resolve"
}
$socket3389 = new-object Net.Sockets.TcpClient
$socket3389.Connect($strComputer, 3389)
if ($socket3389.Connected) {
$c.Cells.Item($intRow, 4) = "Open"
$socket3389.Close()
}
else
{
$c.Cells.Item($intRow, 4) = "Not Open"
}
$Reply = ""
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()