Home > How to use the Exchange Management Shell command syntax
Crash Course:
EMAIL THIS LICENSING & REPRINTS

How to use the Exchange Management Shell command syntax

30 Apr 2008 | Brien Posey

Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google

The Exchange Management Shell (EMS) allows administrators to manage Exchange Server 2007 from the command line. Although most administration tasks can be performed through Exchange 2007's graphical user interface, the Exchange Management Console (EMC), there are some tasks that cannot be accomplished through the console. Here Exchange MVP Brien Posey demystifies the Exchange Management Shell. He explains the basic syntax structure used to perform common commands such as the Get Command.

When trying to understand the purpose of the Exchange Management Shell in Exchange Server 2007 and the ability to perform tasks from the command line, consider the Windows Control Panel. The majority of options available to you through the Control Panel directly affect various registry values. When you implement a setting through the Control Panel, you're editing the system registry. Countless registry settings are only available by running the Registry Editor.

Exchange Server 2007 works in a similar manner. The Exchange Management Console exposes most common Exchange-related settings, but there are several settings that you can't access without using the Exchange Management Shell.

Even if you're familiar with DOS and comfortable working in a command-line environment, the Exchange Management Shell may be intimidating at first. There are multiple commands available, many of which seem quite complex. After working with the Exchange Management Shell further, however, using it isn't too difficult.

Although it's possible to perform all administrative activities directly through the Exchange Management Shell, I don't recommend doing so. I prefer to use the Exchange Management Console and only use the Exchange Management Shell in situations that make using the console impractical. Even if you don't plan to use the Exchange Management Shell, you still should familiarize yourself with how it works and some basic syntax.

The commands used within the Exchange Management Shell follow a verb-noun format; it uses 10 primary verbs (Table 1). This list isn't all-encompassing. Other verbs, such as Export and Connect, are used less frequently.

Verb Description
Get Returns information about the specified object
Set Modifies properties of the specified object
Remove Deletes the specified object
Test Tests the component that you specify
Enable Enables the specified object
Disable Disables the specified object
Install Installs the specified Exchange Server feature
Uninstall Removes the specified Exchange Server feature
New Creates a new Exchange Server object
Move Moves a specified object from one container to another
Table 1. Primary verbs and commands of the Exchange Management Shell.

Verbs are always followed by a dash and a noun. The noun typically refers to an Exchange object; additional parts of the command may refer to individual attributes of that object.

Get command

The Get command in the Exchange Management Shell lets you retrieve information about a specified object. The most familiar Exchange Server object is likely the mailbox. Not surprisingly, the Get command can be used in conjunction with the word Mailbox to retrieve information about a mailbox. If you enter the Get-Mailbox command, you'll see a screen similar to that shown in Figure 1.

Exchange Management Shell Get-Mailbox command Figure 1. The Get-Mailbox command in action. (Click on image for enlarged view.)

The first thing that you may notice on this screen is the yellow text. When the Exchange Management Shell displays command output, warnings are displayed in yellow and errors are displayed in red. In this example, warning messages indicate that mailboxes are corrupt; however, this warning is incorrect.
More Exchange Server 2007 resources:
Step-by-Step: Test driving Exchange Server 2007

Exchange Server 2007 Learning Guide

When you issue the Get-Mailbox command without including any additional parameters, the Exchange Management Shell retrieves information about every mailbox in the entire Exchange Server 2007 organization, regardless of the server on which a mailbox resides. In this particular case, the two mailboxes for which warnings were displayed reside on an Exchange 2003 server.

Exchange Server 2007 uses some mailbox attributes that didn't exist in Exchange Server 2003. When you try to display those mailboxes through the Exchange Management Shell, Exchange 2007 thinks that the mailboxes are corrupt because they are "missing" attributes. Not every Exchange 2003 mailbox appears as corrupt, though. Whether or not the Exchange Management Console lists an Exchange 2003 mailbox as corrupt depends on a few factors.

If you ignore the warning messages, there are two problems with information that the Get-Mailbox command provides.

  • The command lists every mailbox in the entire organization. Because I have a small Exchange organization, all mailboxes fit on a single screen. If you were to issue the Get-Mailbox command in a large organization, the Exchange Management Shell might pull mailbox information for an hour or two. This would be too much information for a single screen and wouldn't be useful.
  • The Get-Mailbox command only displays the mailbox name, its alias, the name of the server that the mailbox resides on and the mailbox quota. If you look at a mailbox's properties sheet in the Exchange Management Console, there are many more mailbox attributes than those being displayed. The Exchange Management Shell limits displayed attributes to prevent information overload.

In its most basic form, the Get-Mailbox command is useful for displaying a quick mailbox summary in a small organization. You can use additional parameters in conjunction with the verb-noun syntax. Typically, however, when additional parameters are used in conjunction with the Get command, they narrow down results or display specific information.

Results that the Get-Mailbox command produces can be changed. For example, to limit the results to mailboxes residing on a specific server, use the following command:

Get-Mailbox –Server servername

Warning messages don't appear in Figure 2 because we're looking at mailboxes residing on an Exchange 2007 server only.

Exchange Management Shell filter query Figure 2. Filter query results by server. (Click on image for enlarged view.)

It's helpful to filter results based on individual attributes. The real issue is knowing which attributes are available. Microsoft offers information related to various commands, including a useful KnowledgeBase article on the Get-Mailbox command. You can also use the -? parameter. Entering Get-Mailbox -? prompts Exchange to display the command's full syntax.

ABOUT THE AUTHOR:   
Brien M. Posey
Brien M. Posey, MCSE
Brien M. Posey, MCSE, is a Microsoft Most Valuable Professional for his work with Exchange Server, and has previously received Microsoft's MVP award for Windows Server and Internet Information Server (IIS). 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 Web site at www.brienposey.com.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Microsoft Exchange Server 2007
Re-enable Exchange Server 2007 remote streaming backups in SP1
How to use Exchange Management Shell's Filter command
Secure Edge Transport servers using the Security Configuration Wizard
What is Windows Server 2008's impact on an Exchange 2007 migration?
Is it time to upgrade users' Windows Mobile devices?
Customizing Outlook Web Access (OWA) in Exchange Server 2007
Managing an Exchange 2007 Cluster Continuous Replication (CCR) setup
Monitor mail flow with the Exchange Server 2007 Queue Viewer tool
Create a global Safe Senders List in Exchange 2007 to filter spam
A primer on Exchange 2007 server roles
Microsoft Exchange Server 2007 Research

Microsoft Exchange Server Scripts and Programming
How to use Exchange Management Shell's Filter command
Fix OWA message size limit issue after Exchange 2007 SP1 upgrade
Automatically save Microsoft Outlook email attachments to disk
Can an admin create out-of-office messages from ESM or AD?
Customize Exchange 2007 mail quota messages from the command line
Windows PowerShell RC2 ready to go
Creating a customized welcome email in Outlook Web Access
Scripting solutions for Exchange Server administrators
Microsoft Outlook script: Banish blank email subject lines
Microsoft Outlook security workaround for administrators and developers

Exchange Server Administration Tips
Re-enable Exchange Server 2007 remote streaming backups in SP1
How to use Exchange Management Shell's Filter command
Why Exchange ActiveSync fails with NAT firewalls
Email archiving and e-discovery best practices for Microsoft Exchange
Secure Edge Transport servers using the Security Configuration Wizard
Is it time to upgrade users' Windows Mobile devices?
Top 10 Microsoft Exchange Server 2003 registry hacks
Monitor mail flow with the Exchange Server 2007 Queue Viewer tool
Use Performance Monitor to detect Exchange 2003 message queue problems
Exchange 2007 memory and hardware configuration best practices

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
application program interface  (SearchExchange.com)
event sink  (SearchExchange.com)
synchronous groupware  (SearchExchange.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsWebcastsWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts