Partilhar via


How to Create a Configuration Manager Console Folder

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 create a Configuration Manager console folder by creating an instance of an SMS_ObjectContainerNode Server WMI Class object. You must supply the following properties:

  • Name - The name of the folder.

  • ObjectType - The type of the folder. For example, 2 for a package folder.

  • ParentContainerNodeID - The node identifier for the parent of the folder.

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.

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
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

Concepts

About Configuration Manager Console Folders
Configuration Manager Objects
How to Create a Configuration Manager Console Folder
How to Create a Configuration Manager Console Folder Item
How to Create a Configuration Manager Console Search Folder
How to Delete a Configuration Manager Console Folder
How to Move a Configuration Manager Console Folder
How to Move a Configuration Manager Console Folder Item