liquidstone
Nieuwe gebruiker
- Lid geworden
- 15 jan 2009
- Berichten
- 1
Ik heb een scriptje gemaakt op een aantal ip adressen te pingen, hij zet het daarna ik een excel bestand. nou wil ik dan als de ping gelukt is dat hij ook de computer naam van de gepingde pc neerzet. nu zet hij alleen het ip neer.
weet iemand hoe ik dit voor elkaar krijg??
mij script
============================================
$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 IP "
$c.Cells.Item(1,2) = "Offline"
$c.Cells.item(1,3) = "Online"
$c.cells.item(1,4) = "date "
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit($True)
$introw = 2
[int]$intPing = 10
[string]$intNetwork = "192.168.54.1"
for ($i=1;$i -le $intPing; $i++)
{
$strQuery = "select * from win32_pingstatus where address = '" + $intNetwork + $i +"'"
$wmi = get-wmiobject -query $strQuery
"Pinging $intNetwork$i ... "
if ($wmi.statuscode -eq 0)
{$c.Cells.Item($intRow, 1) = "$strComputer"
$c.Cells.item($introw, 3)= "Online"
$c.cells.item($introw, 4) = get-date}
else
{$c.Cells.Item($intRow, 1) = "$intnetwork$i"
$c.Cells.Item($intRow, 2) = "Offline"
$c.cells.item($introw, 4) = get-date
}
$introw = $introw + 1
}
weet iemand hoe ik dit voor elkaar krijg??
mij script
============================================
$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 IP "
$c.Cells.Item(1,2) = "Offline"
$c.Cells.item(1,3) = "Online"
$c.cells.item(1,4) = "date "
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit($True)
$introw = 2
[int]$intPing = 10
[string]$intNetwork = "192.168.54.1"
for ($i=1;$i -le $intPing; $i++)
{
$strQuery = "select * from win32_pingstatus where address = '" + $intNetwork + $i +"'"
$wmi = get-wmiobject -query $strQuery
"Pinging $intNetwork$i ... "
if ($wmi.statuscode -eq 0)
{$c.Cells.Item($intRow, 1) = "$strComputer"
$c.Cells.item($introw, 3)= "Online"
$c.cells.item($introw, 4) = get-date}
else
{$c.Cells.Item($intRow, 1) = "$intnetwork$i"
$c.Cells.Item($intRow, 2) = "Offline"
$c.cells.item($introw, 4) = get-date
}
$introw = $introw + 1
}