Solved

WMI - Getting access to the Event Details?

Posted on 2011-03-07
13
654 Views
Last Modified: 2013-12-04
New to WMI.  Have googled a while today, but no luck.

I am generating an error with MySQL (see screenshot attached).

I can get access to a lot of the event info using:
Select * from Win32_NTLogEvent where Type ='Error' and SourceName = 'MySQL'

But I can't seem to get my hands on what I really care about, which is shown in the log viewer in the "box" in the General tag.

I want to get that message "Plugin 'InnoDB' registration as a STORAGE ENGINE failed."

How can I using a WMI query?
0
Comment
Question by:trippy1976
  • 6
  • 5
  • 2
13 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 35068603
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35069484
I forgot to attach the screenshot of the event log viewer.  Also attaching the saved results of my WMI query.  

No, it's sadly not in the Message field... that would be trivial.  I think this is more involved.

Screenshot of the event viewerresult.htm
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35070496
Did you look at the other properties for the Win32_NTLogEvent?

Win32_NTLogEvent Class
http://msdn.microsoft.com/en-us/library/aa394226(v=vs.85).aspx

Is that information in the Data property?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 4

Author Comment

by:trippy1976
ID: 35070758
Yes.  The data is in "InsertionStrings"

I need the information from that object in a WQL query.  

The html doc I attached shows all the properties and their resulting values.  If it were avaialble in a top-level property I wouldn't be posting here :)  Thanks for the help, but I fear the answer to this is "it can't be done"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35070970
InsertionStrings is a string array, so you should be able to get that information from the Win32_NTLogEvent object.
0
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 250 total points
ID: 35071000
don't think it supports on WMI, you may want to use API instead
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35071063
@TheLearnedOne - you can, if you are scripting.  If you are simply doing a WQL query I am not sure if it's possible.

I googled forever, then I turned here.  What I really need is the WMI query that will get the pieces of InsertionString info.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 35071093
Can you show me what you are working with, please?
0
 
LVL 4

Author Closing Comment

by:trippy1976
ID: 35166037
As suspected, you can't query directly to the elements in something like Insertion Strings.  I had to write a VB script to do the query, get the results, and grab that deeper data.  Appears to be the only way to do this.  Thanks everyone.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35169525
Did you come up with the VB script?
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35169798
Yes.  I found the JoinStringsArray function somewhere on google.
strComputer = "."
Set objWMIService = GetObject _
    ( "winmgmts:\\" & strComputer & "\root\cimv2")
	
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent where Type ='Error' and Logfile ='Application' and SourceName='MySQL'")


For Each objItem in colItems     
	strLogString = objItem.TimeGenerated & "," & JoinStringsArray(objItem.InsertionStrings)
Next



Function JoinStringsArray(ByRef aArray)
    If VarType(aArray) = vbNull Then
        JoinStringsArray = ""
        Exit Function
    Else
        JoinStringsArray = Join(aArray)
        JoinStringsArray = Replace(JoinStringsArray, "(NULL)", "")
    End If
End Function

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35171392
You don't need VBScript to do what you have shown.  I don't see anything that it overly complicated, and not achievable with VB.NET/C#.
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35171464
I'm certain you can do it a number of ways.  I really can't go into the specifics of why I needed a VBScript in this case, but it was my choice for workaround.

There was an existing component that could do direct WMI queries, but since you can't get at the info I need via WMI directly I had to go this route.

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

773 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