How to Move 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 move one or more console folders from one location to another by using the SMS_ObjectContainerNodeMoveFolders Method in Class SMS_ObjectContainerNode method. To move a set of folders, call MoveFolders passing an array of folder identifiers (SMS_ObjectContainerNode.ContainerNodeID) and the destination folder identifier (SMS_ObjectContainerNode.ContainerNodeID).
Note
A folder can be moved only within its own folder type (SMS_ObjectContainerNode.ObjectType) folder tree. For example, attempting to move a query folder to a package folder fails.
There is no SMS_ObjectContainerNode object for the root folder. When it is necessary, the root folder can be identified by the value 0.
To move a console folder
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Create an array of the source folders identifiers (SMS_ObjectContainerNode class ContainerNodeID property).
Call the SMS_ObjectContainerNode class MoveFolders property and supply the source identifiers and an identifier for the target console folder.
Example
The following example moves a single console folder, identified by the parameter sourceContainerID to the folder identified by the parameter destinationContainerID.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub MoveConsoleFolder( connection, sourceContainerID, destinationContainerID)
Dim inParameters
Dim folderClass
Dim sourceFolders
On Error Resume Next
' Moving only one folder.
sourceFolders = Array(sourceContainerID)
' Obtain the class definition object of a SMS_ObjectContainerNode object.
Set folderClass = connection.Get("SMS_ObjectContainerNode")
If Err.Number<>0 Then
Wscript.Echo "Couldn't get container node object"
Exit Sub
End If
' Set up the in parameter.
Set inParameters = folderClass.Methods_("MoveFolders").InParameters.SpawnInstance_
inParameters.ContainerNodeIDs = sourceFolders
inParameters.TargetContainerNodeID = destinationContainerID
' Call the method.
Call connection.ExecMethod( "SMS_ObjectContainerNode", "MoveFolders", inParameters)
If Err.Number<>0 Then
Wscript.Echo "Couldn't call method"
Exit Sub
End If
End Sub
public void MoveConsoleFolder(WqlConnectionManager connection, Int32 sourceContainerID, Int32 destinationContainerID)
{
try
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
Int32[] sourceFolders = new Int32[1];//we're only moving one folder hence an array size of 1.
sourceFolders[0] = sourceContainerID;
parameters.Add("ContainerNodeIDs", sourceFolders);
parameters.Add("TargetContainerNodeID", destinationContainerID);
connection.ExecuteMethod("SMS_ObjectContainerNode", "MoveFolders", parameters);
}
catch (SmsException e)
{
Console.WriteLine("Failed to move folder. Error: " + e.Message);
throw;
}
}
The example method has the following parameters:
Parameter | Type | Description |
---|---|---|
connection |
|
A valid connection to the SMS Provider. |
sourceContainerID |
|
The node identifier for the source folder. For more information, see the ContainerNodeIDs parameter of the SMS_ObjectContainerNode class MoveFolders method. |
destinationContainerID |
|
The identifier for the node the source folder is moved to. For more information, see the TargetContainerNodeID parameter of the SMS_ObjectContainerNode class MoveFolders method. |
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 Item