Uisng WMIC to do a WQL Select statement

I have a WQL select statement and a target names space. Can you help me from the WMIC prompt correctly execute this statement?

namespace = root\sms\site_b02
query         = Select * from SMS_ConfigurationItem

I apprecaite your assistance.

John DarbyPMAsked:
Who is Participating?
jkaiosConnect With a Mentor IT DirectorCommented:
Private Sub Form_Load()
   EnumServices "localhost"
End Sub

Public Sub EnumServices(sMachine As String, Optional sUserName As String, Optional sPassword As String)

   Dim oLocator     As Object
   Dim oServices    As Object
   Dim objEnum      As Object
   Dim objInstance  As Object
   Dim sQuery       As String
   sQuery = "SELECT * FROM SMS_ConfigurationItem"
   Set oLocator = CreateObject("WbemScripting.SWbemLocator")
   Set oServices = oLocator.ConnectServer(sMachine, "root\cimv2", sUserName, sPassword)
   Set objEnum = oServices.ExecQuery(sQuery)
   If Err Then
      Debug.Print "Error 0x" & Hex(Err.Number) & " - " & Err.Description
      Exit Sub
   End If
   For Each objInstance In objEnum
      With objInstance
         Debug.Print "Name: " & .Name
      End With
End Sub
John DarbyPMAuthor Commented:
This is a great answer for the other question (WMI query using VBScript). But, I believe this line...

Set oServices = oLocator.ConnectServer(sMachine, "root\cimv2", sUserName, sPassword)

should read...

Set oServices = oLocator.ConnectServer(sMachine, "root\sms\site_<site#>", sUserName, sPassword)
John DarbyPMAuthor Commented:
What I am seeking here is help usig WMIC, the WMI console.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.