*
Quick Links|Home|Worldwide
Microsoft TechNet*
Search Microsoft.com for:
|TechCenters|Downloads|TechNet Program|My TechNet|Security Bulletins|Archive

Exchange Scripting: A Road Map

Doctor Scripto sings Mister Admin

So you're ready jump in and write some Exchange scripts? Excellent! You are obviously a serious scripter, a scripter of substance. To help you on your quest, we're going provide you with a quick overview of Exchange scripting to get you off and running. We'll also offer some pointers to the main resources and code examples you'll need to cook up scripts that will help you manage your Exchange servers.

Microsoft Exchange Server is a rich, complex messaging and collaboration environment closely integrated with Windows and Active Directory. It includes several components that can be used from within system administration scripts to automate Exchange operations. The relationships between these components are a bit complicated, but nothing that you can't master – after all, you're already managing Exchange Server.

*
On This Page
Scripting technologies for working with ExchangeScripting technologies for working with Exchange
Windows Management Instrumentation (WMI)Windows Management Instrumentation (WMI)
Active Directory Service Interfaces (ADSI)Active Directory Service Interfaces (ADSI)
ActiveX Data Objects (ADO)ActiveX Data Objects (ADO)
Collaboration Data Objects (CDO)Collaboration Data Objects (CDO)
CDO for Exchange (CDOEX)CDO for Exchange (CDOEX)
CDO for Exchange Management (CDOEXM)CDO for Exchange Management (CDOEXM)
CDO for Workflow (CDOWF)CDO for Workflow (CDOWF)

Scripting technologies for working with Exchange

We'll focus on four major technology groups. Two of them, Windows Management Instrumentation (WMI) and Active Directory Service Interfaces (ADSI), may already be familiar to you if you've done much system administration scripting. ActiveX Data Objects (ADO) is often used in scripts to search Active Directory and to manage databases such as SQL Server. You may also have encountered the other group, Collaboration Data Objects (CDO), if you've ever used a script to send mail. Exchange enhances CDO with three libraries for Exchange Server administration: CDO for Exchange (CDOEX), CDO for Exchange Management (CDOEXM) and CDO for Workflow (CDOWF). Alphabet soup, anyone?

Together, these technologies enable you to script Exchange Server with VBScript (or any other WSH-compatible scripting language) in a Windows Script Host (WSH) environment. Each of these COM automation libraries gives scripts access to different areas of Exchange Server functionality.

Figure 1   Internet Protocol (TCP/IP) Properties Dialog Box

Figure 1   Exchange Server Scripting Technologies

Note 1: CDOWF works only with the Exchange store, not with ADSI.

Figure 1 shows general relationships among scripting technologies for Exchange Server and Active Directory. This is a very rough representation; for more detailed diagrams of these relationships see Figures 1 and 2 of Alain Lissoir's article, Automating Exchange 2000 Management with Windows Script Host

Windows Management Instrumentation (WMI)

(Included in Windows)

Windows Management Instrumentation (WMI) provides system administration scripters and application developers a consistent way to monitor and manage most of the Windows operating system and the system hardware that supports it. Its providers expose some 800 to 1,000 classes—depending on the version of Windows and applications installed—that model different aspects of operating-system software and hardware.

WMI is designed to work remotely across networks using Distributed Component Object Model (DCOM) and Remote Procedure Call (RPC). Microsoft based WMI on Web-Based Enterprise Management (WBEM), an initiative of the industry-wide Distributed Management Task Force (DMTF) consortium.

For a good introduction to scripting with WMI, see:
Windows 2000 Scripting Guide – WMI Primer

Components of the operating system, computers, applications, and networks are modeled by WMI as classes in the Common Information Model (CIM), the repository defined in the WBEM standard. When Exchange is installed, it adds its own sets of specialized classes to the CIM. Using WMI and its scripting interface, you can manage server information including process, disk space, and memory details, and information on Exchange connector state, queues, server state, services, and store file sizes.

For technical details on WMI, see:
WMI Software Development Kit

When installed on Windows Server, Exchange adds two WMI namespaces, root/cimv2/applications/exchange and root\microsoftexchangev2, to the CIM repository. The classes for this namespace are implemented in 5 additional WMI providers installed along with Exchange:

WMI Exchange Routing Table provider (Exchange 2000)

ExchangeServerState class

ExchangeConnectorState class

WMI Exchange Queue provider (Exchange 2000)

ExchangeLink class

ExchangeQueue class

WMI Exchange Cluster provider (Exchange 2000)

ExchangeClusterResource class

WMI Exchange Message Tracking provider (Exchange 2000 Service Pack 2)

Exchange_MessageTrackingEntry class

WMI Exchange DS Access provider (Exchange 2000 Service Pack 2)

Exchange_DSAccessDC class

Exchange Server 2003 adds 19 new Exchange WMI classes and additional capabilities to four of these existing classes.

For detailed information about WMI functionality in Exchange Server 2003, see:
Microsoft Exchange Server 2003 Software Development Kit - WMI

Active Directory Service Interfaces (ADSI)

(Included in Windows)

Active Directory Service Interfaces (ADSI) is a library of COM automation interfaces that enables scripts to manage Active Directory. It puts a consistent programming and scripting interface over the diverse native APIs of Active Directory. Administrators can use ADSI in scripts to manage users, groups, printers and other resources in the directory.

To start learning about scripting ADSI, see:
Windows 2000 Scripting Guide – ADSI Primer

Exchange Server uses Active Directory as its directory service, and exposes through it many Exchange-specific attributes of directory objects such as users and distribution groups. When Exchange is first installed on Windows Server, it creates a new set of Exchange-specific classes and properties in the Active Directory schema.

Exchange also adds a container to the configuration naming context of Active Directory to hold the configuration data for the Exchange organization. This container is named:
cn=Microsoft Exchange,cn=Services,<configurationNamingContext>

For technical details on ADSI, see:
ADSI Software Development Kit

You can find out more about the modifications Exchange Server 2003 makes to existing Active Directory classes and attributes, and the classes and attributes Exchange Server 2003 adds to Active Directory, at:
Microsoft Exchange Server 2003 Software Development Kit - Active Directory Schema

ActiveX Data Objects (ADO)

(Included in Windows)

ActiveX Data Objects (ADO) is a COM automation library that enables scripts to interact with databases. With it, scripts can use SQL or LDAP queries to do fast searches of Active Directory or Exchange Server. In working with Active Directory, ADO relies on ADSI and the Active Directory OLE DB provider. It accesses the Exchange store through the Exchange OLE DB (ExOLE DB) provider.

For a brief introduction to scripting with ADO, see:
Windows 2000 Scripting Guide – Creating Enterprise Scripts – Working With Databases

For technical details on ADO, see:
ActiveX Data Objects Software Development Kit

ADO works with the Exchange Server 2003 and Exchange 2000 stores. But the information store of Exchange 5.5 is not accessible with ADO because this version does not have an OLE DB provider.

For details on accessing resources in the Exchange store with ADO, see:
Exchange Server 2003 SDK – Architecture - ADO

Collaboration Data Objects (CDO)

(Included in Windows)

Collaboration Data Objects (CDO) enables scripts to create and send e-mail messages. CDO is present on Windows even when Exchange is not installed. Exchange Server 2003 installs three other CDO components over the Windows version of CDO.

In conjunction with ADO and ADSI, CDO can be used to create Web collaboration applications based on Exchange and Active Directory.

For a brief introduction to scripting with CDO, see:
Windows 2000 Scripting Guide – Creating Enterprise Scripts – Sending E-Mail

For technical details on CDO, see:
Collaboration Data Objects Software Development Kit

For details on scripting Exchange with CDO, see:
Exchange Server 2003 SDK – Programming Technologies - CDO

CDO for Exchange (CDOEX)

(Installed with Exchange Server)

The object model of CDOEX is intended for managing folders, messages, appointments, contacts, and other items along with their properties. CDOEX objects also work together with ADSI objects to expose information on users and mailboxes. CDOEX works with ADO 2.5 through OLE DB to provide consistent data access to Active Directory and the Exchange store.

CDOEX provides a superset of CDO functionality — the former installs over and upgrades the latter. Rather than using Messaging API (MAPI) as CDO does, CDOEX relies on standard Internet protocols.

Installed with Exchange Server, CDOEX cannot be installed on a remote machine or called directly through Distributed Component Object Model (DCOM).

For details on CDOEX, see:
Exchange Server 2003 SDK – Reference - CDOEX

CDO for Exchange Management (CDOEXM)

(Installed with Exchange Management Components)

CDOEXM provides an object model for managing Exchange component containers, such as servers, stores, and mailboxes. CDOEXM is implemented as another layer on top of CDO and CDOEX.

CDOEXM is not installed with Exchange Server. Rather, the component is included in Exchange Management Components and can be installed on remote computers and used to manage Exchange servers remotely.

Although the Exchange Server 2003 version of CDOEXM is backwards compatible to Exchange 2000, the Exchange 2000 version can not be used with Exchange Server 2003.

For details on CDOEXM, see:
Exchange Server 2003 SDK – Reference - CDOEXM

CDO for Workflow (CDOWF)

(Installed with Exchange Server)

CDOWF provides tools for writing and managing workflows in the Exchange store. Its object model includes ProcessDefinition, ProcessInstance and WorkflowSession objects. Installed with Exchange Server, CDOWF cannot be installed on a remote machine or called directly through Distributed Component Object Model (DCOM).

For details on CDOWF, see:
Exchange Server 2003 SDK – Reference - CDOWF


 

© 2006 Microsoft Corporation. All rights reserved. Terms of Use |Trademarks |Privacy Statement
Microsoft