Exchange Scripting Revisited

A few months ago, I mentioned some cool scripting tricks for Exchange Server and Windows and promised to revisit the topic. I've been digging further into Exchange scripting in preparation for a new book, and I was a little surprised to learn how many scripting interfaces--each with its own focus and sphere of usefulness--actually exist for Exchange.

The original Collaboration Data Objects (CDO) library was written so that programs could create and manipulate calendar items, mail messages, and contacts in the Exchange store. CDO had its heyday when Windows 98 was new; since then, newer libraries have superseded the original one.

The CDO for Windows 2000 (CDOSYS) library shipped with Windows 2000 and lives on in Windows Server 2003 and Windows XP. This DLL lets you quickly and easily build properly structured MIME and HTML messages--a valuable ability when you write scripts or programs that need to send email.

The CDO for Exchange (CDOEX) libraries (in Exchange Server 5.5 and later) let systems create and modify Exchange objects in the Store. These DLLs are a bit like CDO, only newer.

The CDO for Exchange Management (CDOEXM) library is my current favorite. CDOEXM lets you manage Exchange system objects, including storage groups (SGs) and mailbox databases. Want to create a new mailbox database from a script or move transaction logs to another disk? CDOEXM can perform these tasks and a lot more besides. You can use the ADO interfaces to make databaselike queries against Exchange and Active Directory (AD) data. For example, you can use ADO to find all matching messages in a mailbox after you log on to it. Because several Microsoft interfaces and programs use ADO, most Windows programmers understand it pretty well. The Active Directory Service Interfaces (ADSI) gives you a way to perform required AD actions. You can connect to domain controllers (DCs), locate and manipulate properties of AD objects (ranging from computers and user accounts to organizational units--OUs--and domains), and trigger several system processes.

XML-HTTP scripting isn't a defined interface per se but rather refers to the process of using the WWW Distributed Authoring and Versioning (WebDAV) interface to query or set properties on items in the Exchange Store directly. Not many tools use XML-HTTP, but it provides the greatest degree of control over individual properties of mailbox and public folder items.

These interfaces can be, and usually are, combined. For example, a script to create a new mailbox-enabled user will probably use ADSI and ADO and might use CDOEX to create a welcome message for the user. All these interfaces are well documented on Microsoft Developer Network (MSDN), and many of them feature prominently in Exchange-related Microsoft Knowledge Base articles.

In the coming months, I'll be writing a lot of scripts, and I'll share the most interesting ones with you here. Until then, why not check into these scripting interfaces and see how you can put them to good use? If you've already written some Exchange-related scripts, I'd love to hear about them, too.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish