Get started Bring yourself up to speed with our introductory content.

EMS commands -- beyond the basics

These five Exchange Management Shell commands let you run Exchange from the command line to create distribution groups, HTML reports and .csv files.

Once you have a handle on beginner-level Exchange Management Shell commands, you're ready to move on to more advanced commands. Go beyond the basics to better manage Exchange Server from the command line with these five intermediate-level commands.


Create a distribution group

Although you can create a distribution group through the Exchange Management Console, you can also perform from the Exchange Management Shell. To do so, enter the following command:

New-DistributionGroup -Name '<group name>' -Type 'Distribution' -OrganizationalUnit '<domain name>/Users' -SamAccountName '<account name>' -Alias '<alias name>'

The command requires that you name the distribution group, the security accounts manager account and the group's alias for the new group that you are. You also must provide an organizational unit name, which consists of a domain name and a container.

For example, let's suppose that you wanted to create a distribution group named Managers and place it in the Users container for the Contoso domain. To do so, enter the following command:

New-DistributionGroup -Name 'Managers' -Type 'Distribution' -OrganizationalUnit 'Contoso.com/Users' -SamAccountName 'Managers' -Alias 'Managers'

Create an HTML report

As your Exchange Server organization grows, you'll periodically need to check on the size of your users' mailboxes. In Exchange, the Get-MailboxStatistics command allows you to retrieve information about the number of items in a user's mailbox.

Although this command is handy, it floods the screen with too much information. Fortunately, you can also use this command to create an HTML report, which is much easier to read. To do so, enter the following command:

Get-MailboxStatistics | Select DisplayName, ItemCount | Sort ItemCount | ConvertTo-HTML –Property DisplayName, ItemCount> C:\temp\report.htm

This command retrieves mailbox statistics and then formats the output so that it displays only the mailbox name and the number of items in it. Instead of displaying this information on the monitor, the ConvertTo-HTML portion of the command writes the data to an HTML report. You must use the –Property switch to inform Exchange Server which statistics to include in the report. Additionally, the greater than sign (>) instructs Exchange to redirect the output to the specified file.

Create a .csv file

Creating a .csv file with EMS commands allows you to open it as an Excel spreadsheet. The command to do this is similar to the previous command, except that it uses Export-CSV instead of Export-HTML.

When using the Export-CSV command, you don't need to list the mailbox properties you want to include or use a redirect symbol. To create a .csv file, use the following command:

Get-MailboxStatistics | select DisplayName, TotalItemSize | Export-CSV C:\Temp\Report1.csv

Note: The Get-MailboxStatistics command lets you create an HTML file or a .csv file, but you're not limited to only creating mailbox statistics reports with it. The Exchange Management Shell lets you export any formatted output to either an HTML file or a .csv file. This means that you can just as easily create reports based on the output from the Get-Users or Get-Mailbox commands.

Enable a journaling agent

The Exchange Server journaling feature allows you to perform email archiving without investing in third-party software. This feature uses the transport agent and one or more journaling rules to capture messages as they flow through the transport pipeline. A copy of those messages is then placed into the journal mailbox.

But you must enable the journaling agent before you can use the journaling feature. And because the journaling agent isn't accessible through the Exchange Management Console, you'll need to use the Get-TransportAgent command.

This command informs you whether or not the journaling agent is enabled. If it isn't enabled, enter the Enable-TransportAgent command. Exchange will prompt you to enter the name of the agent you want to enable. Type Journaling Agent to enable this agent the next time you reboot the server.

Mail-enable a public folder

To mail-enable a public folder, type the following EMS command:

Enable-MailPublicFolder –Identity "\<path>\<folder name>"

To mail-enable a folder named \HR\Forms, for example, enter:

Enable-MailPublicFolder –Identity "\HR\Forms"

If you decide that you no longer want the public folder to be mail-enabled, you can mail-disable it using the following command:

Disable-MailPublicFolder –Identity "\<path>\<folder name>"

About the author: Brien M. Posey, MCSE, is a five-time recipient of Microsoft's Most Valuable Professional (MVP) award for his work with Exchange Server, Windows Server, Internet Information Services (IIS), and File Systems and Storage. Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. As a freelance technical writer, Brien has written for Microsoft, TechTarget, CNET, ZDNet, MSD2D, Relevant Technologies and other technology companies. You can visit Brien's personal website at www.brienposey.com.

Do you have comments on this tip? Let us know.

This was last published in May 2010

Dig Deeper on Legacy Exchange Server versions

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchSQLServer

SearchEnterpriseDesktop

SearchVirtualDesktop

Close