Solved

visual studio eventlog1 query events by date/time or WMI query by date/time

Posted on 2010-09-15
3
747 Views
Last Modified: 2012-05-10
I am using the WMI for the following:
Dim objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & myServer & "\root\cimv2")
            Dim colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = '" & Me.cmbEventType.SelectedItem.ToString & "'")


This section below is commented out since I do not know what to use as a filer column
            'and TimeGenerated >='" & Me.dtFrom.ToString & "' and TimeGenerated <='" & Me.dtto.ToString & "'"



This section below is using vb studio 2010 and i do not know how to filter this either for a date/time range.


Me.EventLog1.MachineName = myServer
                'Me.EventLog1.Log = Me.cmbEventType.SelectedItem.ToString
                'myEventLogCount = Me.EventLog1.Entries.Count

                'For m = 0 To myEventLogCount

                '    myDate = Me.EventLog1.Entries.Item(m).TimeGenerated.Month & "/" & Me.EventLog1.Entries.Item(m).TimeGenerated.Day & "/" & Me.EventLog1.Entries.Item(m).TimeGenerated.Year
                '    myTime = Me.EventLog1.Entries.Item(m).TimeGenerated.Hour & ":" & Me.EventLog1.Entries.Item(m).TimeGenerated.Minute & ":" & Me.EventLog1.Entries.Item(m).TimeGenerated.Second
                '    mySource = Me.EventLog1.Entries.Item(m).Source
                '    myCategory = Me.EventLog1.Entries.Item(m).Category
                '    myEvent = Me.EventLog1.Entries.Item(m).EntryType
                '    myUser = Me.EventLog1.Entries.Item(m).UserName

0
Comment
Question by:mphillip85
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 33687689
Hi, the syntax for the date you need is
yyyymmddhhmmss.000000<TimeBias>

eg
20100916095830.000000+600

It's called UTC format:
http://technet.microsoft.com/en-au/library/ee198928.aspx

This would hopefully help you convert your time to UTC in VB.NET:
http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime.aspx

Regards,

Rob.
0
 

Author Closing Comment

by:mphillip85
ID: 33697431
this is what i needed.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33697441
Thanks for the grade.  I'm not that familiar with .NET....would you mind posting the line(s) of code that you used to convert your input box dates to UTC?

Thanks,

Rob.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question