i get no output when polling servers located in my text file ServerList.txt
if i use objServerList = "server1" or objServerList = "." i get the date and
time stamp in an excel spreadsheet.

any help will be much appreciated.
thnx

DJ

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dim colEvents, objEvent, strEventID, objServerList, objServerEventLog, objXL

Const conForReading=1, conForWriting=2, conForAppending=3

'Setup Excel spreadsheet
row = 1
set objXL = WScript.createObject("Excel.Application")
objXL.workbooks.add
objXL.cells(row,1).value = "ComputerName"
objXL.cells(row,2).value = "EventCode"
objXL.cells(row,3).value = "TimeGenerated"
objXL.cells(row,4).value = "message"

'Search System Event Logs for an specific Event ID
strEventID = InputBox("Enter the Event ID to search for: ", "System Event
Logs", "6005")

'Input and Output File Locations
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Read Server Names from a text file
Set objServerList =
objFSO.OpenTextFile("C:\temp\ServerList.txt",conForReading)

'objServerList = "server1"
'objServerList = "."


'Collect Event ID's from ServerList
Set colEvents = GetObject("WinMgmts://" & objServerList &
"/root/cimv2").execQuery("select * from win32_ntlogevent where
logfile='system' and eventcode="& strEventID)

For Each objEvent In colEvents

' Write the values into the Excel spreadhseet
row=row+1
objXL.cells(row,1).value = objEvent.ComputerName
objXL.cells(row,2).value = objEvent.EventCode
objXL.cells(row,3).value = objEvent.TimeGenerated
objXL.cells(row,4).value = objEvent.message
objXL.cells(row,5).RowHeight = 12.75

Next

'Make Excel Visible
objXL.Visible = True

MsgBox ("Search is complete!")

Re: check all servers for event 6005 by Torgeir

Torgeir
Mon May 30 09:10:59 CDT 2005

DJ wrote:

> i get no output when polling servers located in my text file ServerList.txt
> if i use objServerList = "server1" or objServerList = "." i get the date and
> time stamp in an excel spreadsheet.
>
> any help will be much appreciated.
Hi,

You will need to enumerate the lines in the ServerList.txt file. You
should also ping the computers before doing a WMI connection in case
some of the computers are offline.

See the script here for an example on both:
http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/3fbd1f467c6a171a?dmode=source&hl=en



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: check all servers for event 6005 by e

e
Mon May 30 09:23:17 CDT 2005

"=?Utf-8?B?REo=?=" <DJ@discussions.microsoft.com> wrote in
news:132FA207-CBF1-4E67-A2F1-07CDB8310AF5@microsoft.com:

> i get no output when polling servers located in my text file
> ServerList.txt if i use objServerList = "server1" or objServerList =
> "." i get the date and time stamp in an excel spreadsheet.
>
> any help will be much appreciated.
> thnx
>
> DJ
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Dim colEvents, objEvent, strEventID, objServerList, objServerEventLog,
> objXL
>
> Const conForReading=1, conForWriting=2, conForAppending=3
>
> 'Setup Excel spreadsheet
> row = 1
> set objXL = WScript.createObject("Excel.Application")
> objXL.workbooks.add
> objXL.cells(row,1).value = "ComputerName"
> objXL.cells(row,2).value = "EventCode"
> objXL.cells(row,3).value = "TimeGenerated"
> objXL.cells(row,4).value = "message"
>
> 'Search System Event Logs for an specific Event ID
> strEventID = InputBox("Enter the Event ID to search for: ", "System
> Event Logs", "6005")
>
> 'Input and Output File Locations
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> 'Read Server Names from a text file
> Set objServerList =
> objFSO.OpenTextFile("C:\temp\ServerList.txt",conForReading)
>
> 'objServerList = "server1"
> 'objServerList = "."
>
>
> 'Collect Event ID's from ServerList
> Set colEvents = GetObject("WinMgmts://" & objServerList &
> "/root/cimv2").execQuery("select * from win32_ntlogevent where
> logfile='system' and eventcode="& strEventID)
>
> For Each objEvent In colEvents
>
> ' Write the values into the Excel spreadhseet
> row=row+1
> objXL.cells(row,1).value = objEvent.ComputerName
> objXL.cells(row,2).value = objEvent.EventCode
> objXL.cells(row,3).value = objEvent.TimeGenerated
> objXL.cells(row,4).value = objEvent.message
> objXL.cells(row,5).RowHeight = 12.75
>
> Next
>
> 'Make Excel Visible
> objXL.Visible = True
>
> MsgBox ("Search is complete!")
>

Not too related, but here are some Excel functions (the big ones are
broke for some reason) I have written;

Sub FormatRange(Range,Format,Width)
objExcel.ActiveSheet.Range(Range).Select
If Format <> "" Then
objExcel.Selection.NumberFormat = Format
End If
If Width <> "" Then
objExcel.Columns(Range).ColumnWidth = Width
End If
End Sub

Sub WriteCellLoc(Loc,Value,Bold)
objExcel.ActiveSheet.Range(Loc).Activate
objExcel.ActiveCell.Value = Value
objExcel.ActiveCell.Font.Bold = Bold
End Sub

Sub WriteCellAdv(SheetName,Val1)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write2CellAdv(SheetName,Val1,Val2)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write3CellAdv(SheetName,Val1,Val2,Val3)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(0,2).Value = Val3
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write4CellAdv(SheetName,Val1,Val2,Val3,Val4)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(0,2).Value = Val3
objExcel.ActiveCell.Offset(0,3).Value = Val4
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write5CellAdv(SheetName,Val1,Val2,Val3,Val4,Val5)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(0,2).Value = Val3
objExcel.ActiveCell.Offset(0,3).Value = Val4
objExcel.ActiveCell.Offset(0,4).Value = Val5
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write6CellAdv(SheetName,Val1,Val2,Val3,Val4,Val5,Val6)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(0,2).Value = Val3
objExcel.ActiveCell.Offset(0,3).Value = Val4
objExcel.ActiveCell.Offset(0,4).Value = Val5
objExcel.ActiveCell.Offset(0,5).Value = Val6
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub Write21CellAdv
(SheetName,Val1,Val2,Val3,Val4,Val5,Val6,Val7,Val8,Val9,Val10,Val11,Val12
,Val13,Val14,Val15,Val16,Val17,Val18,Val19,Val20,Val21)
objExcel.Sheets(SheetName).Select
objExcel.ActiveCell.Value = Val1
objExcel.ActiveCell.Offset(0,1).Value = Val2
objExcel.ActiveCell.Offset(0,2).Value = Val3
objExcel.ActiveCell.Offset(0,3).Value = Val4
objExcel.ActiveCell.Offset(0,4).Value = Val5
objExcel.ActiveCell.Offset(0,5).Value = Val6
objExcel.ActiveCell.Offset(0,6).Value = Val7
objExcel.ActiveCell.Offset(0,7).Value = Val8
objExcel.ActiveCell.Offset(0,8).Value = Val9
objExcel.ActiveCell.Offset(0,9).Value = Val10
objExcel.ActiveCell.Offset(0,10).Value = Val11
objExcel.ActiveCell.Offset(1,0).Activate
objExcel.ActiveCell.Value = ""
objExcel.ActiveCell.Offset(0,2).Value = Val12
objExcel.ActiveCell.Offset(0,3).Value = Val13
objExcel.ActiveCell.Offset(0,4).Value = Val14
objExcel.ActiveCell.Offset(0,5).Value = Val15
objExcel.ActiveCell.Offset(0,6).Value = Val16
objExcel.ActiveCell.Offset(0,7).Value = Val17
objExcel.ActiveCell.Offset(0,8).Value = Val18
objExcel.ActiveCell.Offset(0,9).Value = Val19
objExcel.ActiveCell.Offset(0,10).Value = Val20
objExcel.ActiveCell.Offset(0,11).Value = Val21
objExcel.ActiveCell.Offset(1,0).Activate
End Sub

Sub GotoWorksheet(SheetName)
objExcel.Sheets(SheetName).Select
objExcel.ActiveSheet.Range("A1").Activate
End Sub

Sub RenameWorksheet(OldSheet, NewSheet)
objExcel.Sheets(OldSheet).Select
objExcel.ActiveSheet.Name = NewSheet
objExcel.ActiveSheet.Range("A1").Activate
End Sub

Sub GotoCell(Location)
objExcel.ActiveSheet.Range(Location).Activate
End Sub

Sub AdvanceLine(Down,Across)
objExcel.ActiveCell.Offset(Down, Across).Activate
End Sub

Sub MilDate(Variable)
Variable = Day(Now) & Left(Month(Now), 3) & Right(Year(Now), 2)
End Sub




Re: check all servers for event 6005 by DJ

DJ
Tue May 31 09:28:08 CDT 2005

thats exactly what i need to see.. thnx for your help

"Torgeir Bakken (MVP)" wrote:

> DJ wrote:
>
> > i get no output when polling servers located in my text file ServerList.txt
> > if i use objServerList = "server1" or objServerList = "." i get the date and
> > time stamp in an excel spreadsheet.
> >
> > any help will be much appreciated.
> Hi,
>
> You will need to enumerate the lines in the ServerList.txt file. You
> should also ping the computers before doing a WMI connection in case
> some of the computers are offline.
>
> See the script here for an example on both:
> http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/3fbd1f467c6a171a?dmode=source&hl=en
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: check all servers for event 6005 by Dr

Dr
Tue May 31 11:03:07 CDT 2005

JRS: In article <Xns966669ADF4958eholleycoxnet@207.46.248.16>, dated
Mon, 30 May 2005 07:23:17, seen in news:microsoft.public.scripting.vbscr
ipt, e <eholley@cox.net> posted :
>
>Sub MilDate(Variable)
> Variable = Day(Now) & Left(Month(Now), 3) & Right(Year(Now), 2)
>End Sub
>

One should not evaluate the date (by Now) repeatedly; if it changes, one
may get a substantial error if the year changes before the third call,
and if it does not change then calling three times is a waste of time -
unless the system is cleverer than it seems safe to expect.

If that language is like my VBscript, it gives 31505 for today. And it
will give (this year) 11105 on both Jan 11th and Nov 1st.

The only sensible numeric format for days is YYYYMMDD; see ISO 8601. I
believe that it is also given in a FIPS, which must be why Americans
tend not to use it.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.