In Microsoft System Center Configuration Manager 2007, you move one or more console folders from one location to another by using the SMS_ObjectContainerNode MoveFolders 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).

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

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

  2. Create an array of the source folders identifiers (SMS_ObjectContainerNode class ContainerNodeID property).

  3. Call the SMS_ObjectContainerNode class MoveFolders property and supply the source identifiers and an identifier for the target console folder.


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.

Visual Basic Script  Copy Code
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
C#  Copy Code
public void MoveConsoleFolder(WqlConnectionManager connection, Int32 sourceContainerID, Int32 destinationContainerID)
		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);

The example method has the following parameters:

Parameter Type Description


  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.


  • Managed: Int32

  • VBScript: Integer

The node identifier for the source folder. For more information, see the ContainerNodeIDs parameter of the SMS_ObjectContainerNode class MoveFolders method.


  • Managed: Int32

  • VBScript: Integer

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:










Robust Programming

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


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

See Also

Send comments about this topic to Microsoft.