In Microsoft System Center Configuration Manager 2007, to create a Configuration Manager console search folder, you set the following properties of the SMS_ObjectContainerNode Server WMI Class object:

SearchFolder - Boolean value that indicates that the folder is a search folder.

SearchString - An XML data structure that defines the search. For more information, see Configuration Manager Search Folder XML.

FolderFlags - Search folder flags. In most cases this is set to 1, indicating that the search includes all folders of the same type.

To create a console search folder

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

  2. Create an SMS_ObjectContainerNode object.

  3. Set the SMS_ObjectContainerNode object SearchFolder property to true.

  4. Set the SMS_ObjectContainerNode object SearchString property to the search XML.

  5. Set the SMS_ObjectContainerNode object FolderFlags property to 1.

  6. Commit the SMS_ObjectContainerNode object.


The following example creates a search folder. The parameter name is the name that the search folder is created with. The identifier for the folder that the search folder is created in, is ]parentNodeID, and searchXML is the XML search data.

The following is an example XML string for searchXML that searches for a package with the identifier JBS00004:

Remove the @ character from the beginning of the string for use with VBScript.
  Copy Code
@"<SearchFolderDescription xmlns:xsi="""" xmlns:xsd="""" Name=""SMS_Package""><SearchFolderDescriptionItems>
	<SearchFolderDescriptionItem PropertyName=""PackageID"">

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

Visual Basic Script  Copy Code
Sub  CreateSearchFolder(connection, name, objectType, parentNodeID, searchXML)

	Dim folder
	Set folder = connection.Get("SMS_ObjectContainerNode").SpawnInstance_()
	If Err.Number<>0 Then
		Wscript.Echo "Couldn't get container node item class"
		Exit Sub
	End If

	folder.Name = name
	folder.ObjectType = objectType
	folder.ParentContainerNodeID = parentNodeID
	folder.SearchFolder = true
	folder.SearchString = searchXML
	folder.FolderFlags = 1


End Sub  
C#  Copy Code
public void CreateSearchFolder(WqlConnectionManager connection, string name, Int32 objectType, Int32 parentNodeID, string searchXML)

		IResultObject folder = connection.CreateInstance("SMS_ObjectContainerNode");

		folder["Name"].StringValue = name;
		folder["ObjectType"].IntegerValue = objectType;
		folder["ParentContainerNodeID"].IntegerValue = parentNodeID;
		folder["SearchFolder"].BooleanValue = true;
		folder["SearchString"].StringValue = searchXML;
		folder["FolderFlags"].IntegerValue = 1;



	catch (SmsException eX)
		Console.WriteLine("Failed to create search folder. Error: " + eX.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 name of the console folder to create.


  • Managed: int32

  • VBScript: integer

The type of object the folder is being created for. For more information, see the SMS_ObjectContainerNode class ObjectType property.


  • Managed:Int32

  • VBScript: Integer

The node the console folder is created in. For more information, see the SMS_ObjectContainerNode class ParentContainerNodeID property.


  • Managed: String

  • VBScript: String

The search criteria. For more information, see Configuration Manager Search Folder XML.

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.