Quick and easy ways to complete daunting tasks

\[Editor's Note: Some material in this column was adapted from Chapter 5 of Managing Microsoft Exchange Server, ISBN 1565925459. The information appears here courtesy of the publisher, O'Reilly & Associates.\]

In "Super Export and Import Tools," August 2000, I explored the basics of Microsoft Exchange Administrator's directory export and import features. Now for the big payoff: Learn how to overcome onerous tasks such as exporting the entire Global Address List (GAL), exporting and importing custom attributes, and batch-creating mailboxes and Windows NT domain accounts simultaneously.

Take the Command (Line)
You can use the admin.exe command-line tool to run Exchange Administrator; the tool's /e and /i options let you automate exports and imports, respectively. When you use this command-line tool instead of the process that I explained in "Super Export and Import Tools," you can easily export items for import into a non-Exchange Server directory or import data from such a directory. To use admin.exe, type the following at the command prompt:

admin \{/e | /i\} /d
 \[/n\] \[/o \]

The /e and /i switches toggle between export and import mode. The csvfile variable specifies the full path to the Comma Separated Values (CSV) file that you want to export or import. (For more information about CSV files, see "Super Export and Import Tools.") In export mode, if the specified CSV file exists, Exchange Administrator uses that file's existing header; if the CSV file doesn't exist, Exchange Administrator uses the default set of export headers. In import mode, the specified CSV file must exist and contain a valid header, or Exchange Administrator will return an error.

In export mode, /d dirservername tells Exchange Administrator which Exchange directory server to contact to retrieve the data. (This server is the same one you selected from the MS Exchange server drop-down list in Exchange Administrator's Tools, Directory Export dialog box when you exported the CSV file.) In import mode, /d dirservername specifies which server will receive the imported data.

The optional /n switch forces Exchange Administrator to hide its progress dialog—a useful option when you're automating exports or imports as part of a scripted or scheduled operation. The optional /o optionsfile switch specifies the full path to an options file that you can use to control the exported or imported information. (To learn more about options files, see the sidebar "Know Your Options.") For example, the following command uses the gal.txt options file to control an export from my primary Exchange server (i.e., hawk), using the mailbox.csv file from the Exchange Server CD-ROM:

admin /e mailbox.csv /d hawk /o gal.txt

Mission 1: Conquer the GAL
People frequently ask me how to export the entire GAL: a useful trick when you have users (e.g., 3Com's PalmPilot users, Microsoft Outlook Web Access—OWA—users) who can't use the Outlook Offline Address Book (OAB) or when you want to give an outside organization access to your GAL's contents without exposing an Exchange server. (Beware: Exporting a large organization's GAL can take a long time, and the resulting file might be too large for a handheld device or Web page.)

To export the GAL, you need an export options file that specifies the correct starting point for the export operation. For example, I can use the following file to export the GAL from my organization (i.e., ra):

\[export\]
basepoint=/o=ra
exportobject=mailbox
informationlevel=full
subcontainers=yes

This file tells Exchange Administrator to start from the organization level (i.e., /o) and export all information for all mailboxes and subcontainers (including recipient containers). You can then use Microsoft Excel macros, an ActiveState Perl script, a VBScript program, or any other method to remove, reformat, add, or edit the data.

Mission 2: Customize, Customize, Customize
Exchange Server lets you define custom attributes for each mailbox, distribution list (DL), and custom recipient. By default, Exchange Server names these attributes Custom Attribute 1 through Custom Attribute 10, but most people change these names (e.g., rename Custom Attribute 1 to Employee Hire Dates, rename Custom Attribute 2 to Employee ID). If you keep the default attribute names, you can use those names to export and import the attribute values. If you change the attribute names, you can use the modified names to export and import the values, but you might be unable to properly reimport your data. To fix this problem, use the attribute's directory name, rather than the display name, in your import file (e.g., use Extension-Attribute-2, rather than Custom Attribute 2 or Employee ID, as the attribute name in your export or import file's header). Apart from this minor adjustment, you can easily read, modify, and change custom attribute values as you would for any other attribute type—no muss, no fuss.

Mission 3: Whip Up a Batch (of Mailboxes and Domain Accounts)
Administrators who are migrating users from another mail system frequently need to create a batch of mailboxes. This procedure is easy if you use the Create mode I discussed in August. However, you might want to create mailboxes and NT domain accounts at the same time—for example, when migrating users away from a UNIX-based mail host. To complete this task, you need to create an options file to instruct Exchange Administrator. Also, the PDC for the domain in which you're creating the mailboxes must be available, and the import must occur on the server on which you want to locate the new mailboxes. For example, the following import options file tells Exchange Administrator to use NT security on the files, to create new NT accounts for the new mailboxes, and to not generate random passwords:

\[import\]
applyntsecurity=yes
createntaccounts=yes
generatepassword=no
ntdomain=ra

When I specify this options file as part of the admin.exe import command, Exchange Administrator creates the accounts in the ra domain. The resulting CSV import file will look like the following:

Obj-Class,Mode,Directory Name,
Alias Name,Display Name,E-Mail Address,Home-Server

Mailbox,Create,Jason McNamara,
Jason,Jason McNamara,SMTP:
jason@robichaux.net,HSV1

This file contains the Mode property, as well as a directory name, display name, alias email address, and home server for each recipient. These properties are required. You can use the import options file to specify more attributes, or you can specify a recipient template to permit Exchange Administrator to copy the account details for you.

As I've shown you in my most recent columns, Exchange Administrator's export and import features are extremely flexible. You can use these tools to create, remove, or modify any Exchange Server recipient object, big or small.