You move one or more Microsoft System Center Configuration Manager 2007 console folder items from one location to another by using the SMS_ObjectContainerNode MoveMembers Method in Class SMS_ObjectContainerItem method. To move a set of items, call MoveMembers passing an array of item instance keys—the source folder identifier, the destination folder identifier, and the type of the item.

An item can be moved only within its own folder type (SMS_ObjectContainerItem.ObjectType). For example, attempting to move a query item to a package folder fails.

The instance key for an item is guaranteed to be unique only for the same type of item. For example, a package item can have the same instance key as an advertisement item. The type of the item (SMS_ObjectContainerItem.ObjectType) should be inspected to ensure that the correct item is moved.

Configuration Manager 2007 objects in the root folder of a given type do not have an associated SMS_ObjectContainerItem instance. To overcome this, pass 0 to the ContainerNodeID parameter of MoveMembers.

To move a console folder item

  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 container identifiers for the folders you want to move.

  3. Call the SMS_OBjectContainerItem class MoveMembers method to move the folders to the destination folder.


The following example moves a console folder item that is identified by the item object identifier (ItemObjectID) and object type (objectType). SourceContainerID is the source folder and destinationContainerID is the destination folder

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

Visual Basic Script  Copy Code
Sub MoveConsoleFolderItem(connection, _
						itemObjectID, _
						objectType,   _
						sourceContainerID, _
	Dim inParameters
	Dim outParamemters
	Dim itemClass
	Dim sourceItems

	 On Error Resume Next

	' Moving only one folder.
	sourceItems = Array(itemObjectID)

	' Obtain the class definition object of a SMS_ObjectContainerNode object.
	Set itemClass = connection.Get("SMS_ObjectContainerItem")

	If Err.Number<>0 Then
		Wscript.Echo "Couldn't get container node item class"
		Exit Sub
	End If

	' Set up the in parameters.
	Set inParameters = itemClass.Methods_("MoveMembers").InParameters.SpawnInstance_
	WScript.Echo sourceItems(0)
	inParameters.InstanceKeys = sourceItems
	inparameters.ContainerNodeID = sourceContainerID
	inParameters.TargetContainerNodeID = destinationContainerID
	inParameters.ObjectType = objectType
	' Call the method.
	Set outParameters = _
		connection.ExecMethod( "SMS_ObjectContainerItem", "MoveMembers", inParameters)
	If Err.Number<>0 Then
		Wscript.Echo "Couldn't call method"
		Exit Sub
	End If
End Sub		
C#  Copy Code
public void MoveConsoleFolderItem(WqlConnectionManager connection, string itemObjectID, Int32 objectType, Int32 sourceContainerID, Int32 destinationContainerID)
		Dictionary<string, object> parameters = new Dictionary<string, object>();
		string[] sourceItems = new string[1];
		// Only one item is being moved, the array size is 1.

		sourceItems[0] = itemObjectID;
		parameters.Add("InstanceKeys", sourceItems);
		parameters.Add("ContainerNodeID", sourceContainerID);
		parameters.Add("TargetContainerNodeID", destinationContainerID);
		parameters.Add("ObjectType", objectType);
		connection.ExecuteMethod("SMS_ObjectContainerItem", "MoveMembers", parameters);
	catch (SmsException e)
		Console.WriteLine("Failed to move folder item. 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: String

  • VBScript: String

The item's key. For more information, see the SMS_ObjectContainerItem class InstanceKey property.


  • Managed: Int32

  • VBScript: Integer

The item type. For more information, see the SMS_ObjectContainerItem class ObjectType property.


  • Managed: Int32

  • VBScript: Integer

The identifier for the source console folder. For more information, see the SMS_ObjectContainerNode class ContainerNodeID property.


  • Managed: Int32

  • VBScript: Integer

The identifier for the destination console folder. For more information, see the SMS_ObjectContainerNode class ContainerNodeID property.

Compiling the Code






Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine (Only required if the connection manager is of type WqlConnectionManager.)



See Also

Send comments about this topic to Microsoft.