Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

January 22, 2004 12:00 AM

Exchange Scripting Revisited

Windows IT Pro
InstantDoc ID #41558
Rating: (0)

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.

Related Content:

ARTICLE TOOLS

Comments
  • Jason Price
    8 years ago
    Jan 27, 2004

    I've written a script to dump the contents of each mailbox in the Global Address List to a web page. I have another script that creates the index for the generated pages.

    The scripts run nightly in case there have been changes, such as new mailboxes added. I used JScript as the scripting language and ADO and ADSI to access Exchange 5.5.

    I created web page templates so I didn't need to hard code the HTML in my script. The script reads in the template at the beginning. It creates an ADO recordset by querying Exchange, using ADSI.

    The script spins through the recordset and writes one HTML page for each record. The HTML page is created by replacing the placeholders in the template with fields in the recordset. It uses regular expressions to do this.

    The index page is generated in a similar manner. The ADO recordset is handy, because you can sort the data easily before you create the index page.

    The script gets its configuration settings from an XML file, so it can be changed easily without needing to modify the code.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.