phenry194
Posts: 196
Score: 0 Joined: 3/30/2007 Status: offline
|
OK, here is what I have used when looking for a file. I didn't write it, I just edit it as needed depending on what I am looking for. It pings the machine, puts a message on the screen if it can't reach it via ping, and dumps the information of if a file is installed or not into an excel spreadsheet. What I would like to do is incorporate the ping function into the script above so it doesn't dump a entry into the log saying it's not installed just because it is offline. I just haven't managed to find a way to combine the two scripts so it will work. Here you go. Thanks. : ) ## *********** Beginning of function Pingme *********** function PingMe ($pc) { $ping = new-object System.Net.NetworkInformation.Ping $rslt = $ping.send("$pc") if ($rslt.status –eq “Success”) { write-host (“ping $pc worked”) -foregroundcolor "Yellow" return $true } else { "" write-warning “$pc is not reachable” return $false } } # End of function PingMe ############################################################ $ErrorActionPreference = "SilentlyContinue" $EXobj = New-Object -comobject Excel.Application $EXobj.visible = $True $book = $EXobj.Workbooks.Add() $col = $book.Worksheets.Item(1) $col.Cells.Item(1,1) = "Machine Name" $col.Cells.Item(1,2) = "WSE 3.0" $dd = $col.UsedRange $dd.Interior.ColorIndex = 19 $dd.Font.ColorIndex = 11 $dd.Font.Bold = $True $dd.EntireColumn.AutoFit() $row = 2 foreach ($pc in get-content c:\temp\counterPCs.txt) { $online=PingMe($pc) if ($online -eq $true) { $newpath="\\$pc\c$\program files\Microsoft WSE\v3.0\wse.config" get-item $newpath if ($? -eq $true) { $col.Cells.Item($row,1) = $pc $col.Cells.item($row,2) = "installed" } else { $col.Cells.Item($row,1) = $pc $col.Cells.item($row,2) = "Not installed" } $row = $row + 1 } }
|