Trouble running wmi query from .NET

Posted on 2009-02-12
Last Modified: 2012-05-06
Good day,
Has anyone out there ever tried to run a remote WMI query for RAID levels of hard drives on IBM servers?
We run a hardware RAID on our servers using LSI controllers. These controllers report to the IBM director agent running on the servers. IBM director installs a set of CIM tools to query information about the hardware. I found the IBM manual that details the classes available here :
I am using a standard .NET managementObjectSerarcher to query the server. I have been able to successfully query the standard objects under the CIMV2 namespace but I haven't been able to crack the code so to speak on this namespace. I'm sure I am missing something. The code I am using is below. The class and namespace I am trying to query is in the code. I get an error saying 'Invalid Class'. Any Ideas?

Hopefully this is understandable!
Public Shared Function getDrives(ByVal sName As String) As DataTable

        Dim options As New ConnectionOptions

        options.Impersonation = ImpersonationLevel.Impersonate

        options.Authentication = AuthenticationLevel.Packet

        Dim mScope As New ManagementScope("\\" & sName & "\root\PG_Internal", options)

        ' The documentation notes that this namespace is installed with IBM director also

        'Dim mScope As New ManagementScope("\\" & sName & "\root\PG_InterOp", options)

        ' And this one

        'Dim mScope As New ManagementScope("\\" & sName & "\root\IBMSD", options)

        ' This is the class that the documentation contains the information I want

        Dim mQuery As New SelectQuery("SELECT * FROM IBMPSG_RAIDDiskDrive")

        Dim mSearcher As New ManagementObjectSearcher(mScope, mQuery)

        ' build the datatable

        Dim mPropertiesTable As New DataTable

        Dim mPropertiesRow As DataRow

        Dim dcDriveLetter As New DataColumn("Letter", GetType(String))        mPropertiesTable.Columns.Add(dcDriveLetter)



            ' Check the connection

            If mScope.IsConnected Then

                ' traverse through each record given

                For Each driveObj As ManagementObject In mSearcher.Get()

                    ' Create a new row for the datatable

                    mPropertiesRow = mPropertiesTable.NewRow

                    ' Traverse through the properties found...

                    For Each driveProperty In driveObj.Properties

                        ' Create the header row

                        If mPropertiesTable.Columns.Count <> driveObj.Properties.Count + 1 Then

                            Dim dcDriveProperty As New DataColumn(driveProperty.Name, GetType(String))


                        End If

                        ' Get the property value

                        mPropertiesRow(driveProperty.Name) = driveProperty.Value


                    ' Add the row



            End If

            ' Return the datatable

            Return mPropertiesTable

        Catch ex As Exception

            ' Return a datatable showing the exception

            mPropertiesRow = mPropertiesTable.NewRow()

            mPropertiesRow("Letter") = ex.Message.ToString & "[" & System.Security.Principal.WindowsIdentity.GetCurrent().Name & "]"


            Return mPropertiesTable

        End Try

    End Function

Open in new window

Question by:GCPSlanops
    LVL 3

    Expert Comment

    Hi GCPSlanops,

    Can you post the whole exception please including line number?

    Also you could change your first "Dim mScope" line to the below to help split out sections of the code to find the bug.
    Dim sScopeQuery AS String = "\\" & sName & "\root\PG_Internal"
    Dim mScope As New ManagementScope(sScopeQuery, options)

    Open in new window


    Accepted Solution

    Thanks for the reply. I understand why you ask for that but I have singled the problem out to the class that is being called. I am not calling it right apparently. Using the exact syntax I can successfully query any standard Win32 class from root\cimv2. When I change the query to root\IBMSD, i can query certain classes and get results. So, it isn't necessarily the syntax of the query. The error I get is when the query runs (line 12) and it simply states 'Invalid Class'. I assume that is because the class doesn't exist but according to the documentation from IBM, the class I am looking for [IBMPSG_RaidDiskDrive] should exist in one of the three namespaces [IBMSD, PG_InterOp, or PG_Internal] but as of yet I cannot find it. I even downloaded the WMI object browser and looked for the class on the server I am querying. I haven't seen it... I do actually have a support contract with IBM for IBM director so I might need to contact them...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    More or less everybody in the IT market understands the basics of Networking, however when we start talking about Storage Networks, things get a bit dizzier, and this is where I would like to help.
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now