• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1394
  • Last Modified:

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.

Thanks,
JohnD
0
John Darby
Asked:
John Darby
  • 2
1 Solution
 
jkaiosCommented:
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
   Next
   
End Sub
0
 
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)
0
 
John DarbyPMAuthor Commented:
What I am seeking here is help usig WMIC, the WMI console.

Thanks,
JohnD
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now