In Microsoft System Center Configuration Manager 2007, you create a Configuration Manager console folder by creating an instance of an SMS_ObjectContainerNode Server WMI Class object. You must supply the following properties:

The other properties are provided by the SMS Provider when the object is created.

Note
There is no SMS_ContainerNode for the root folder. A folder can be created in the root folder of a particular folder type by setting ParentContainerNodeID to 0 and setting ObjectType to the folder's type.

After it is created, the SMS_ObjectContainerNode object ContainerNodeID contains the folder identifier. You use this value when creating child folders or when adding items to the folder. For more information, see How to Create a Configuration Manager Console Folder Item.

To create a console folder

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

  2. Create an instance of the SMS_ObjectContainerNode class.

  3. Populate the Name, ObjectType, and ParentContainerNodeID properties.

  4. Commit the changes.

Example

The following example creates a new folder based on the supplied name, object type, and parent node.

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

Visual Basic Script  Copy Code
Sub CreateConsoleFolder(connection, name, objectType, parentNodeID)

	Dim folder

	Set folder = connection.Get("SMS_ObjectContainerNode").SpawnInstance_()
	folder.Name = name
	folder.ObjectType = objectType
	folder.ParentContainerNodeID = parentNodeID

	folder.Put_

 End Sub
C#  Copy Code
public void CreateConsoleFolder(WqlConnectionManager connection, string name, Int32 objectType, Int32 parentNodeID)
{
	try
	{
		IResultObject folder = connection.CreateInstance("SMS_ObjectContainerNode");
		folder["Name"].StringValue = name;
		folder["ObjectType"].IntegerValue = objectType;
		folder["ParentContainerNodeID"].IntegerValue = parentNodeID;

		folder.Put();
}
	catch (SmsException e)
	{
		Console.WriteLine("Failed to create folder. 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.

Name

  • Managed: String

  • VBScript: String

The name of the console folder to create.

objectType

  • Managed: Int32

  • VBScript: Integer

The type of object the folder is being created for. For more information, see the SMS_ObjectContainerNode class ObjectType property.

parentNodeID

  • Managed:Int32

  • VBScript: Integer

The node the console folder is created in. For more information, see , see the SMS_ObjectContainerNode class ParentContainerNodeID 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.