Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Tail Logfile with WMI

Reply
 
Old 01-15-2009   #1 (permalink)
Peter Bauer


 
 

Tail Logfile with WMI


Hi

I have a script wich copy files from a remote machine to the local machine
with WMI, but the logs went bigger and bigger and now I search for a
possibility, not to move the complete logfile but rather to tail the logfile
or move only the new events from this logfile. Do you have any clue how I can
realize this ?

Thanks
Peter

My System SpecsSystem Spec
Old 01-15-2009   #2 (permalink)
Tom Lavedas


 
 

Re: Tail Logfile with WMI

On Jan 15, 2:49*am, Peter Bauer <PeterBa...@xxxxxx>
wrote:
Quote:

> Hi
>
> I have a script wich copy files from a remote machine to the local machine
> with WMI, but the logs went bigger and bigger and now I search for a
> possibility, not to move the complete logfile but rather to tail the logfile
> or move only the new events from this logfile. Do you have any clue how Ican
> realize this ?
>
> Thanks
> Peter
Maybe this modification of the Script Center's example will help ...

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root
\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' " _
& "and RecordNumber > '9800'")

For Each objEvent in colLoggedEvents
Wscript.Echo "Category: " & objEvent.Category
Wscript.Echo "Computer Name: " & objEvent.ComputerName
Wscript.Echo "Event Code: " & objEvent.EventCode
Wscript.Echo "Message: " & objEvent.Message
Wscript.Echo "Record Number: " & objEvent.RecordNumber
Wscript.Echo "Source Name: " & objEvent.SourceName
Wscript.Echo "Time Written: " & objEvent.TimeWritten
Wscript.Echo "Event Type: " & objEvent.Type
Wscript.Echo "User: " & objEvent.User
Next

Just change the record number to match your particular situation and
update it as required. You'll probably want to automate it in your
script to read the latest record (first in a log file, I believe) of
the last dump you have on hand. In that case, change the query to use
a variable, something like this ...

Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' " _
& "and RecordNumber > '" & nRecNumb & "'")

HTH,

Tom Lavedas
***********
http://there.is.no.more/tglbatch/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
tail -f file | cut ...? PowerShell
head and tail in PS? PowerShell
Tail functionality? PowerShell
Re: grep, which, and tail commands? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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