Compartir a través de


How to Read a Configuration Manager Object by Using WMI

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

In Microsoft System Center Configuration Manager 2007, you read a Configuration Manager object by using the SWbemServices object Get method to return an object instance that is identified by a key value.

Note

to query for multiple objects, use either a synchronous or asynchronous query. For more information, see How to Perform a Synchronous Configuration Manager Query by Using Managed Code

To read a Configuration Manager object

  1. Set up a connection to the SMS Provider. For more information, see How to Connect to an SMS Provider in Configuration Manager by Using WMI.

  2. Using the SWbemServices object that you obtain from step 1, call the Get method and specify the class and key information for the object you want.

Example

The following VBScript code example function displays the name and description for a supplied key package identifier (packageID).

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Sub DisplayPackageName (connection, packageID)
    
    On Error Resume Next 
    Dim package

    Set package = connection.Get("SMS_Package.PackageID='" & packageID & "'")
    If Err.Number<>0 Then
        Wscript.Echo "Couldn't get package " + packageID
        Exit Sub
    End If
    
    Wscript.Echo "Package Name: " + package.Name
    Wscript.Echo "Package Description: " + package.Description
    
End Sub

This example method has the following parameters:

Parameter Type Description

connection

SWbemServices

A valid connection to the SMS Provider.

packageID

String

A package identifier. This can be obtained from the SMS_Package class PackageID property.

See Also

Concepts

Configuration Manager Objects Overview
How to Call a Configuration Manager Object Class Method by Using WMI
How to Connect to an SMS Provider in Configuration Manager by Using WMI
How to Create a Configuration Manager Object by Using WMI
How to Delete a Configuration Manager Object by Using WMI
How to Modify a Configuration Manager Object by Using WMI
How to Perform an Asynchronous Configuration Manager Query by Using WMI
How to Perform a Synchronous Configuration Manager Query by Using WMI
How to Read Lazy Properties by Using WMI
How to Use Configuration Manager Objects with WMI

Other Resources

https://go.microsoft.com/fwlink/?LinkId=43950