Using the Exchange Administrator Directory Export/Import Utility


CrossLinks


In this article, we’ll look at various ways you can access the Exchange Administrator Directory Export/Import utility, including the Exchange graphical user interface and command-line switches. We will also explore ways to automate the export-import process using batch files and explain how doing so can provide an extra measure of security for your Exchange data.


Exporting data


Microsoft Exchange offers a Directory Export feature under the Tools menu that can be used to export data to a text file. You can use Directory Export to do the following:

  • Back up directory information
  • Export directory information to another e-mail system
  • Create a text file of all properties for mailboxes, custom recipients, or distribution lists
  • Create a text file that can be used by Directory Import to import directory information When you export your data, the Directory Export utility creates a text file with the following header information: obj-class, first name, last name, display name, alias name, directory name, primary Windows NT account, home-server, e-mail address, e-mail addresses, members, obj-container, and hide from AB. This file can be viewed or edited easily in Microsoft Excel.


    Importing data


    Microsoft Exchange also includes a Directory Import feature under the Tools menu that can be used to import data from a text file. You can use Directory Import to do the following:

  • Add new mailboxes
  • Import directory information from another e-mail system
  • Add or change personal information (such as phone number and mailbox space quotas) to existing mailboxes and custom recipients
  • Create distribution lists and populate them with members
  • Modify directory attributes of all services in a site If you have a text file created using the export feature, you can modify the information in it and then import it to overwrite or append existing information.


    Using command-line switches


    The Exchange Administrator graphical interface is useful for most tasks, but will not allow you to automate tasks. You can use command-line switches to set up an export/import data operation automatically. You can also incorporate these switches into a batch file, which you can run quickly at any time or run on a schedule. The switches that we will focus on are for export (/e) and import (/i). They are not case-sensitive. The following syntax runs the command-line directory export utility: /e You use the switch like this: admin /e export_file /d directory_server_name /n /o options_file Table 1 describes the various options. Only the /e switch is required; all other switches are optional.
    Table 1: Directory export command options.

    Options Description
    export_file The name of the file where the exported directory information will be written.
    directory_server_name The name of the server from which the directory information will be exported.
    /n Specifies that the progress bar is not displayed during directory export.
    /o Specifies the name of an export options file.
    options_file The name of a directory export options file that contains the options that control how the directory information is exported.

    The following switch runs the command-line directory import utility: /i You use the switch like this: admin /i import file /d directory_server_name /n /o options_file Table 2 describes the various options. Only the /i switch is required; all other switches are optional.
    Table 2: Directory import command options.

    Option Description
    <import file> The name of the file that contains directory information to be imported.
    <directory server name> The name of the server whose directory is to be updated.
    /n Specifies that the progress bar is not displayed during directory import.
    /o Specifies the name of an import options file.
    <options file> The name of a directory import options file containing options that control how directory information is imported.


    Export and import options files


    When you’re running the command-line directory export utility with the /o option, the export options file is used to specify the same types of options as the Directory Export dialog box used in the GUI. Each option has a default value. If you want to use all the default values, it is not necessary to even use the /o switch. The export options file is a text file and must be in the following format: [Export]
    DirectoryService=<DS server name> (default=NULL)
    HomeServer=<server name> (default=NULL)
    Basepoint=<DN of basepoint object> (default=NULL, which indicates the organization)
    Container=<RDN of container object> (default=Recipients)
    ExportObject=[Mailbox, Remote (custom recipients), (default=Mailbox) DL, Recipients (all recipients), All (all object types)]
    InformationLevel=[None, Minimal, Full] (default=Minimal)
    BasepointOnly=[Yes, No] (default=No)
    RawMode=[Yes, No] (default=No)
    Hiddenobjects=[Yes, No] (default=No)
    Subcontainers=[Yes, No] (default=No)
    CodePage=[-1,0,code-page-ID] (Default=0)
    ColumnSeparator=<ASCII value of column separator character> (Default=44) (“,”)
    MVSeparator=<ASCII value of multivalue separator character> (Default=37) (“%”)
    QuoteCharacter=<ASCII value of quoted value delimiter> (Default=34) (“)
    If you use an import options file, it must be in the following format: [Import]
    DirectoryService=<DS server name> (default=NULL)
    Basepoint=<DN of basepoint object> (default=NULL, which indicates the local site)
    Container=<RDN of container object> (default=Recipients)
    InformationLevel=[None, Minimal, Full] (default=Minimal)
    RecipientTemplate=<DN of default mailbox> (default=none)
    NTDomain=<NT domain where accounts will be created> (default=none)
    OverwriteProperties=[Yes, No] (default=No)
    CreateNTAccounts=[Yes, No] (default=No)
    DeleteNTAccounts=[Yes, No] (default=No)
    ApplyNTSecurity=[Yes, No] (default=Yes)
    GeneratePassword=[Yes, No] (default=No)
    RawMode=[Yes, No] (default=No)
    CodePage=[-1,0,code-page-ID] (Default=0)
    ColumnSeparator=<ASCII value of column separator character> (Default=44) (“,”)
    MVSeparator=<ASCII value of multivalue separator character> (Default=37) (“%”)
    QuoteCharacter=<ASCII value of quoted value delimiter> (Default=34) (“)
    An example of an options file looks like this: [Export]
    DirectoryService=Server1 //**This specifies the server that contains the directory service
    HomeServer=Server1 //**This specifies the server from which to export
    ExportObject=Mailbox //**Specify the object you want to export
    RawMode=No //** The RawMode option is primarily intended for developers and should be enabled only by //**advanced users. Raw mode requires specific information about the directory schema.
    Hiddenobjects=Yes //**This allows you to export object that are hidden
    Subcontainers=Yes //**This allows you to export subcontainers


    Automating the process with a batch file


    You can use the command-line directory export utility to export directory information to a text file. The next step is to create a batch file for the export process that saves you from retyping the information each time. This process may seem unnecessary if you perform a regular backup, but the Jet database format that Microsoft Exchange Server version 5.X uses can become corrupt. It may be possible to repair a corrupt database using the Exchange utilities, but they cannot fix every problem. It is even possible to back up a corrupt database without realizing it. At that point, it may be impossible to restore the database from a meaningful backup–and the directory export utility will come in very handy. The following batch file uses the Admin.exe program with the /e option to export the Exchange database data. It also incorporates the /o switch to point to an Options file that contains information about the server from which to retrieve information. Contents of CSV.bat: ADMIN /e C:siteDATA.CSV /o C:siteOPTION.TXT When you run the batch file, the Admin program will take some time to initialize. After it initializes, it exports the data to the file you specified in the batch file. Even if you have multiple Exchange Servers, you can use a single batch file to produce the export files by copying the existing lines in the batch file and changing them to point to the correct files and servers. It takes only a few minutes to create the batch file, and you do not have to stop the services to run it. Depending on the size of your database, the batch file can take less than a minute to run or up to an hour. The time that it takes to create the batch file and run it is short in comparison to the time it can save you in the event of data corruption.


    Scheduling the batch file


    Windows NT has a built-in Schedule. To schedule events, you must start the Schedule service. To schedule a command, you use the atutility. The syntax is as follows: at [<computername>] To schedule the CSV.bat file to run every workday during off hours, you would type: at 02:30 /EVERY:M,T,W,Th,F “C:sitecsv.bat” You can also use the winat utility to schedule a command. This utility is shipped with the NT Resource Kit and adds a graphical interface to the at command. Another advantage of winatis that it automatically starts the Schedule service on the target machine. If you are running Windows 2000, the process is much simpler. Open Scheduled Tasks from Control Panel and choose Add Scheduled Task. Doing so will launch the Schedule Task Wizard, which leads you through the process. By incorporating the Admin.exe command into a batch file and then scheduling it, you can rest a little easier knowing that your Exchange data will be recoverable in the event of database corruption. // Troy Thompson, MCSE+Internet, is a freelance consultant in the Louisville, Ky., area.

  • Get the Free Newsletter!
    Subscribe to Daily Tech Insider for top news, trends & analysis
    This email address is invalid.
    Get the Free Newsletter!
    Subscribe to Daily Tech Insider for top news, trends & analysis
    This email address is invalid.

    Latest Articles

    Follow Us On Social Media

    Explore More