How to Delete 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, a folder is deleted by deleting its associated SMS_ObjectContainerNode Server WMI Class object. The folder is identified by the SMS_ObjectContainerNode.ContainerNodeID property.
Note
The console folders provide a view into the items they contain. When a folder is deleted, any folders and items that it contains are not deleted; rather, they are moved to the root folder.
To delete a console folder
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Get the SMS_ObjectContainerNode object instance for the console folder you want to delete.
Call the connection object Delete method to delete the console folder.
Example
The following example deletes a folder identified by its node identifier (nodeID).
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub DeleteConsoleFolder(connection, nodeID)
Dim folder
Set folder = connection.Get("SMS_ObjectContainerNode.ContainerNodeID=" + CStr(nodeID) + "")
folder.Delete_
End Sub
public void DeleteConsoleFolder(WqlConnectionManager connection, Int32 nodeID)
{
try
{
IResultObject folder = connection.GetInstance(@"SMS_ObjectContainerNode.ContainerNodeID=" + nodeID + "");
folder.Delete();
}
catch (SmsException e)
{
Console.WriteLine("Failed to delete package. Error: " + e.Message);
throw;
}
}
The example method has the following parameters:
Parameter | Type | Description |
---|---|---|
connection |
|
A valid connection to the SMS Provider. |
nodeID |
|
The identifier for the console folder. For more information, see 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
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 Move a Configuration Manager Console Folder
How to Move a Configuration Manager Console Folder Item