-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpinglistvirt.ps1
46 lines (37 loc) · 1007 Bytes
/
pinglistvirt.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$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) = "Server"
$c.Cells.Item(1,2) = "IP Address"
$c.Cells.Item(1,3) = "Ping Status"
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit($True)
$intRow = 2
$list = Import-Csv C:\Serverlist2.txt
#$colComputers = get-content C:\Serverlist1.txt
foreach($entry in $list)
#foreach ($strComputer in $colComputers)
{
$entry.IPAddress
$c.Cells.Item($intRow, 1) = $entry.ServerName
$c.Cells.Item($intRow, 2) = $entry.IPAddress
#ServerName,IPAddress
$ping = new-object System.Net.NetworkInformation.Ping
$Reply = $ping.send($entry.IPAddress)
if ($Reply.status –eq “Success”)
{
$c.Cells.Item($intRow, 3) = “Online”
}
else
{
$c.Cells.Item($intRow, 3) = "Offline"
}
$Reply = ""
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()