Subscribe to Windows IT Pro
July 10, 2001 12:00 AM

Command-Line Mailbox Creation

Windows IT Pro
InstantDoc ID #21465
Rating: (0)
A convenient method for a common task

Almost every Exchange administrator creates mailboxes at some point. In Exchange Server 5.5, you can use a variety of methods for creating accounts. Small companies might use Microsoft Exchange Administrator, and large companies might rely on third-party utilities. However, scripting gives you the best options. Let's look at how you can use a script to create Exchange mailboxes in Exchange 5.5. Because Exchange 2000 Server works differently, you must use a different technique in that Exchange version.

Why Script?
Although Exchange 2000 is available, administrators still create many thousands of mailboxes in Exchange Server 5.5. Creating mailboxes with a script is a simple and often overlooked technique. Scripting offers several advantages. First, scripting ensures that you create mailboxes the same way every time. Second, by using a script, you minimize the possibility for administrator error. For example, it's easy to skip a field when you're using a GUI, whereas a script can verify fields before it creates the mailbox. Third, a script helps you adhere to company mailbox standards (e.g., naming conventions). Fourth, you eliminate reliance on the Exchange Administrator program GUI for simple tasks and gain some advantages, such as access to five attributes not available in the GUI. Finally, scripting gives you a great deal of flexibility. Changing an area code or SMTP address for thousands of mailboxes becomes a less daunting procedure with scripting.

To automate mailbox creation, you need to create an import file, then use a batch file to create a new mailbox. However, you must first decide what you want to include in the import file.

Making an Import File
Import files contain, at a minimum, one line containing header information and one line containing data about objects such as mailboxes, distribution lists (DLs), or custom recipients. The header information consists of properties found in the schema. (The schema defines the attributes associated with objects and the values associated with attributes.) For a quick look at header information, open Exchange Administrator and click Tools, Directory Export. Click Export File, and enter the name testexport.csv. Save the file in a temporary directory so that you can delete it later, then click Export. Exporting won't remove or delete information from the directory. Open the file in Notepad or Microsoft Excel to see an example of a Directory Export file, such as the file Figure 1 shows.

The data you choose to include in the import file depends on the information in the header. In other words, you can import fax number information only if the Fax Number attribute is in the header. A mailbox can hold more than 60 attributes with a default Exchange installation, but you don't need all the attributes to create a new mailbox. At a minimum, the header information for a mailbox contains the Obj-Class, Directory Name, and Home-Server attributes; however, that information isn't sufficient for a business mailbox. An import file usually contains many more attributes, such as Primary Account, which you use to link a Windows NT user or group and its permissions to a mailbox. Therefore, you need to select the attributes you want to include in the import file.

Selecting Attributes
The Directory Export method, which I explained in the previous section, exports only a fraction of the attributes available. There are two ways to display the entire list of attributes. The first method is to use the Header program, which you can obtain from the Microsoft BackOffice Resource Kit. Header is a simple utility that exposes directory attributes by object. Header lets you generate a Comma Separated Value (CSV) attribute file for mailboxes, DLs, and other objects.

The second method for viewing attributes is to use Microsoft's mailbox.csv file, which contains a ready-made comma-delimited list of mailbox attributes. The Microsoft article "XADM: Sample CSVs Not Included on Exchange Server 5.0 or 5.5 CD" (http://support.microsoft.com/support/kb/articles/q169/7/61.asp) explains where you can download mailbox.csv, .csv files for DLs, and other sample .csv files.

From the comprehensive list of attributes, you determine which attributes you want when you create an account. With the .csv file of all the mailbox attributes, you're ready to export all the mailbox information from the directory. From Exchange Administrator, use the same directory export procedure, but this time, select the Header or mailbox.csv file as the export file. When you click Export, Exchange reads the attributes from the .csv file and dumps mailbox information for each attribute from the directory to the .csv file. Exchange renames the original file with the new extension .c01.

Open the newly populated .csv file in a spreadsheet program such as Excel. Go through the headers to determine the attributes to use for importing new mailboxes. To make the fields easier to view in Excel, select Format, Column, AutoFit Selection. When you find the attributes you don't need, delete those columns from the spreadsheet until you've narrowed the list down to your final choices. When the spreadsheet displays only the needed attributes, save the spreadsheet in CSV format. Now you can use attributes from this import file and a script to create a mailbox.

Related Content:

ARTICLE TOOLS

Comments
  • Adam
    8 years ago
    Jan 06, 2004

    Really good, works like a charm but now I need some script to delete a 5.5 mailbox.

    Can anyone help

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

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