Exchange Server 2003 provides five new Windows Management Instrumentation (WMI) providers and 15 new WMI classes. As I showed you in "Managing Exchange 2003 with WMI, Part 1," January 2004, http://www.winnetmag.com/microsoftexchangeoutlook, InstantDoc ID 40755, these new providers and classes let you easily manage Exchange servers, logons, and mailboxes. The new providers and classes also let you easily manage Exchange public foldersa welcomed addition. All earlier versions of Exchange lack easy-to-use programmable capabilities for managing public folders. Although Collaboration Data Objects for Exchange Management (CDOEXM) and the Exchange OLEDB provider (through ADO) offer some public folder management capabilities, most Exchange administrators and programmers find CDOEXM and the Exchange OLEDB provider difficult to use.
The two WMI classes related to public folder management are Exchange_FolderTree and Exchange_PublicFolder. The WMI provider ExchangeFolderTreeProvider supports the Exchange_FolderTree class, which represents the public folder hierarchies available on the Exchange 2003 server to which you're connected. This class exposes a set of read-only properties and no methods. Therefore, this class only retrieves information about public folder hierarchies.
The WMI provider ExchangePublicFolderProvider supports the Exchange_PublicFolder class, which represents instances of all public folders across all existing public folder hierarchies available on the Exchange 2003 server to which you're connected. Note that this WMI provider doesn't support system public folders, such as Schedule+ Free/Busy. The Exchange_PublicFolder class exposes several methods and many read/write properties that let you manage public folders. Because the class exposes so many properties, I won't cover them all here. However, the scripting technique you use for most of the properties is similar; only the property name and parameters change.
Let's look at how to use the Exchange_FolderTree and Exchange_PublicFolder classes to perform several common public folder management tasks. Specifically, let's look at how to view public folder hierarchies, update a public folder's administrative note and replication schedule, create and delete public folders, and perform other public folder operations.
Viewing Public Folder Hierarchies
In "Exchange 2000 SP2 WMI Updates," January 2003, http://www.winnetmag.com/microsoftexchangeoutlook, InstantDoc ID 27211, I presented a script named GetCollectionOfInstances.wsf that you can use to list all instances of a WMI class. You can download GetCollectionOfInstances.wsf and all the other scripts I discuss in this article from the Exchange & Outlook Administrator Web site. Go to http://www.winnetmag.com/microsoftexchangeoutlook, enter InstantDoc ID 27211 in the InstantDoc ID text box, then click Download the Code. To run these scripts, you must have administrative privileges to the Exchange system. You must also have either administrative privileges (if you're accessing the namespace remotely) or user privileges (if you're accessing the namespace locally) to the Windows system. If you're using user privileges, make sure you can locally log on to the server.
GetCollectionOfInstances.wsf uses a WMI Query Language (WQL) data query to retrieve the desired information. Thus, to view all instances of the Exchange_FolderTree class (i.e., to view all the public folder hierarchies) on an Exchange server, you use the WQL data query
Select * From
Exchange_FolderTree