Erstellen eines Configuration Manager Objekts mithilfe von WMIHow to Create a Configuration Manager Object by Using WMI
Sie erstellen in Configuration Manager ein Configuration Manager Objekt, indem Sie das-Objekt SpawnInstance_ -Methode von " errbemubject " aufrufen.You create a Configuration Manager object, in Configuration Manager, by calling the SWbemObject object SpawnInstance_ method.
Das Swap -Objekt ist die Klassendefinition für den Objekttyp, den Sie erstellen möchten.The SWbemObject is the class definition for the object type that you want to create. Beispielsweise SMS_Package.For example, SMS_Package. Sie rufen das Swap -Objekt durch Aufrufen der Get -Methode von " errbemservices " ab.You get the SWbemObject by calling the SWBemServices object Get method.
So erstellen Sie ein Configuration Manager ObjektTo create a Configuration Manager object
Richten Sie eine Verbindung mit dem SMS-Anbieter ein.Set up a connection to the SMS Provider. Weitere Informationen finden Sie unter Herstellen einer Verbindung mit einem SMS-Anbieter in Configuration Manager mithilfe von WMI.For more information, see How to Connect to an SMS Provider in Configuration Manager by Using WMI.
Verwenden Sie das in Schritt 1 abzurufende Objekt " Swap-Dienste ", rufen Sie " Get " auf, um das " errbemjebject " für Configuration Manager die Objektklassen DefinitionUsing the SWBemServices object you obtain from step one, call Get to get the SWbemObject for the Configuration Manager object class definition.
Rufen Sie SpawnInstance_ für das "errbemubject" auf, um das neue-Objekt zu erstellen.Call SpawnInstance_ on the SWbemObject to create the new object. Ein-Objekt wird für das neue-Objekt zurückgegeben.An SWbemObject is returned for the new object.
Füllen Sie die Objekteigenschaften mit dem aus dem-aufruten aufzurufenden Austausch aus.Using the SWbemObject returned from the call to SpawnInstance, populate the object properties.
Ruft Put_ auf, um das neue Objekt an den SMS-Anbieter zu übergeben.Call Put_ to commit the new object to the SMS Provider.
BeispielExample
Im folgenden VBScript-Codebeispiel wird ein SMS_Package -Objekt erstellt.The following VBScript code example creates an SMS_Package object.
Informationen zum Aufrufen des Beispielcodes finden Sie unter Aufrufen von Configuration Manager-Codeausschnitten.For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub CreatePackage (connection)
On Error Resume Next
' Create a package object.
Set package = connection.Get("SMS_Package").SpawnInstance_()
If Err.Number<>0 Then
Wscript.Echo "Couldn't create packages object"
Exit Sub
End If
' Populate the object.
package.Name = "Test Package"
package.Description = "A test package"
package.PkgSourceFlag = 2
package.PkgSourcePath = "C:\temp"
package.Put_
If Err.Number<>0 Then
Wscript.Echo "Couldn't commit the package"
Exit Sub
End If
WScript.Echo "Package created"
End Sub
Diese Beispiel Methode verfügt über die folgenden Parameter:This example method has the following parameters:
ParameterParameter | typeType | BESCHREIBUNGDescription |
---|---|---|
Connection |
SWbemServicesSWBemServices | Eine gültige Verbindung mit dem SMS-Anbieter.A valid connection to the SMS Provider. |
Kompilieren des CodesCompiling the Code
Weitere InformationenSee Also
Windows-Verwaltungsinstrumentation Windows Management Instrumentation
Übersicht über Objekte Gewusst wie: Abrufen einer Configuration Manager-Objektklassen Methode mithilfe von WMI Objects overview How to Call a Configuration Manager Object Class Method by Using WMI
Vorgehensweise beim Herstellen einer Verbindung mit einem SMS-Anbieter in Configuration Manager mithilfe von WMI How to Connect to an SMS Provider in Configuration Manager by Using WMI
Löschen eines Configuration Manager Objekts mithilfe von WMI How to Delete a Configuration Manager Object by Using WMI
Vorgehensweise beim Ändern eines Configuration Manager Objekts mithilfe von WMI How to Modify a Configuration Manager Object by Using WMI
Ausführen einer asynchronen Configuration Manager Abfrage mithilfe von WMI How to Perform an Asynchronous Configuration Manager Query by Using WMI
Ausführen einer synchronen Configuration Manager Abfrage mithilfe von WMI How to Perform a Synchronous Configuration Manager Query by Using WMI
Vorgehensweise beim Lesen eines Configuration Manager Objekts mithilfe von WMI How to Read a Configuration Manager Object by Using WMI
Lesen von faulen Eigenschaften mithilfe von WMIHow to Read Lazy Properties by Using WMI