In Microsoft System Center Configuration Manager 2007, because there are no SMS_ObjectContainerItem Server WMI Class instances for Configuration Manager 2007 objects in the root folder of a given Configuration Manager object type, a new SMS_ObjectContainerItem instance must be created for each Configuration Manager object that is moved from the root folder to a subfolder. For example, when reports in the root folder are organized into more meaningful folders, a new SMS_ObjectContainerItem instance must be created for each report that is placed in a subfolder.

The following properties must be supplied when you create an instance of SMS_ObjectContainerItem:

To create a console folder item

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Create an SMS_ObjectContainerItem object.

  3. Populate the object properties.

  4. Commit the changes.

Example

The following example creates a new console folder item for a Configuration Manager object that is identified by its instance identifier (instanceID) and its object type (objectType). The new folder item is created in the folder identified by nodeID.

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

Visual Basic Script  Copy Code
Sub CreateConsoleFolderItem(connection, instanceID, objectType, nodeID)

	Dim folderItem
	Set folderItem = connection.Get("SMS_ObjectContainerItem").SpawnInstance_()

	folderItem.InstanceKey = instanceID
	folderItem.ObjectType = objectType
	folderItem.ContainerNodeID = nodeID

	folderItem.Put_

End Sub   
C#  Copy Code
public void CreateConsoleFolderItem(WqlConnectionManager connection, string instanceID, Int32 objectType, Int32 nodeID)
{
	try
	{
		IResultObject folderItem = connection.CreateInstance("SMS_ObjectContainerItem");

		folderItem["InstanceKey"].StringValue = instanceID;
		folderItem["ObjectType"].IntegerValue = objectType;
		folderItem["ContainerNodeID"].IntegerValue = nodeID;

		folderItem.Put();
}
	catch (SmsException e)
	{
		Console.WriteLine("Failed to create folder item. Error: " + e.Message);
		throw;
}
}

The example method has the following parameters:

Parameter Type Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

InstanceID

  • Managed: String

  • VBScript: String

The item's key. For more information, see the SMS_ObjectContainerItem class InstanceKey property.

objectType

  • Managed: Int32

  • VBScript: Integer

The item type. For more information, see the SMS_ObjectContainerItem class ObjectType property.

nodeID

  • Managed: Int32

  • VBScript: Integer

The type of the item. For more information, see the SMS_ObjectContainerItem class ContainerNodeID property and the SMS_ObjectContainerNode class ContainerNodeId property.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.

See Also


Send comments about this topic to Microsoft.