Topic Last Modified: 2007-01-31
By David Strome
New in Microsoft Exchange Server 2007 is the Exchange Management Shell, a powerful management interface, built on Microsoft Windows PowerShell technology. You can use the Exchange Management Shell to perform every task available in the Exchange Management Console and tasks that you can't perform in the Exchange Management Console. What's more, when you perform a task in the Exchange Management Console, the same command is made available to the Exchange Management Shell and called to process the request.
Figure 1 shows the Exchange Management Shell in action.
At first glance, the shell may look daunting to those unfamiliar with the command line. But let's take a look at the cool stuff you can do and how easy it is to get started:
Before you get started with the Exchange Management Shell, it's helpful to understand a few basic concepts.
Parameter Position
1
Get-Mailbox "Kim Akers"
Get-Mailbox -Identity "Kim Akers"
Get-MailboxDatabase Sales | Get-Mailbox | Move-Mailbox -TargetDatabase Research
Windows PowerShell snap-ins are collections of cmdlets used to administer an application or major component. If you don’t load the snap-in for the specific application, you can’t use its associated cmdlets.
What does that mean to you? If you start PowerShell without loading the Exchange Management Shell snap-in, and try to issue an Exchange Management Shell cmdlet, such as Get-Mailbox, you’ll get an error. Why? Because the Get-Mailbox cmdlet doesn’t exist in the core set of PowerShell cmdlets.
So first things first: Let's open the Exchange Management Shell. Simply click Start, click Programs, Microsoft Exchange Server 2007, and then Exchange Management Shell.
For more background information to get you started, see New Administration Functionality in the Exchange Management Shell.
For Exchange 2007, the Microsoft Exchange User Education team has developed a robust set of documentation, available inside the Exchange Management Shell and in the Exchange Server 2007 Help file that is available in the Exchange Management Console and online.
In the shell, you'll find that the Get-Help cmdlet is an invaluable resource as you learn to navigate the Exchange Management Shell. And be sure to check out the Operations section in the Exchange Server 2007 Help file. It includes dozens of procedural topics that will help you perform most administrative tasks by using the Exchange Management Shell and the Exchange Management Console. You can access the Exchange Server 2007 Help file from the Start menu of Exchange 2007 and online at Microsoft Exchange Server 2007.
In the shell itself, use the Get-Help cmdlet to access cmdlet-specific help in a variety of formats. Typing Get-Help by itself displays general help information. And the Get-Help cmdlet is even more powerful when you start supplying parameters.
To get help for a specific cmdlet, type Get-Help followed by the cmdlet you want information about, such as Get-Help Get-SystemMessage. By default, the shell displays a description of the cmdlet and its syntax. It suppresses other sections that may not be used by all administrators.
You can control what information is presented to you by using the Detailed, Full, and Example parameters. Just add them to the end of the command. For example, Get-Help –Full returns all the help sections available for a cmdlet. Try the commands out for yourself to see what information is displayed for your favorite cmdlets.
If you want to retrieve information about a specific parameter or parameters on a cmdlet, you can use the Parameters parameter with the Get-Help cmdlet. For example, if you want to view all the parameters and their descriptions on the Set-Mailbox cmdlet that contain the word “quota”, type Get-Help Set-Mailbox –Parameter *quota*.
Or maybe you want to view a list of cmdlets that manage a specific server role or component feature or that affect objects across a certain scope of functionality. You can do this by using the Get-Help cmdlet and three parameters: Role, Component, and Functionality. When you use the Get-Help cmdlet with these parameters, remember to enclose the values that you specify with these parameters in wildcard characters (*). The following are examples of how to call Get-Help with each parameter:
The “Getting Help” topic in the Exchange Server 2007 Help file lists all the role, component, and functionality values that can be used.
By default, when command output is displayed to the screen, the Exchange Management Shell displays only a subset of the available properties for each object. Why? Because each object can contain dozens of properties, and you'll want to optimize the command output for your needs. You can easily access and view all these properties by piping the output of a command to the following three formatting cmdlets: Format-List, Format-Table, and Format-Wide.
Format-List and Format-Table are most frequently used so let's look at them more closely.
The Format-List cmdlet takes input from the pipeline and outputs a vertical columned list of all the specified properties of each object. You can specify which properties you want to display by using the Property parameter, which is a positional parameter. If you call the Format-List cmdlet without any parameters specified, all properties are output. The Format-List cmdlet wraps lines instead of truncating them. One of the best uses for the Format-List cmdlet is to override the default output of a cmdlet so that you can retrieve additional or more focused information, as in this example, Get-DistributionGroup | Format-List Name, *OnlyFrom, PrimarySmtpAddress, *Size*. Figure 2 shows the output of this command.
Get-DistributionGroup | Format-List Name, *OnlyFrom, PrimarySmtpAddress, *Size*
The Format-Table cmdlet lets you display items in a table format with labeled headers and columns of property data. By default, many cmdlets, such as the Get-Mailbox and Get-JournalRule cmdlets, use the table format for output. Among the parameters for the Format-Table cmdlet are the Properties and GroupBy parameters. These work exactly as they do with the Format-List cmdlet. To display long lines of property information completely instead of truncating at the end of a line, use the Wrap parameter with the Format-Table cmdlet, as in the following example: Get-Mailbox -Database Research | Format-Table Name, ProhibitSendQuota, Database -Wrap. Figure 3 shows the output of this command.
Get-Mailbox -Database Research | Format-Table Name, ProhibitSendQuota, Database -Wrap
You can also specify a wildcard character "*" with a partial property name with both the Format-List and Format-Table Cmdlets, as I showed in Figure 2. If you include a wildcard character, you can match multiple properties without having to type each property name individually. For example, Get-Mailbox | Format-List -Property Email* returns all properties that begin with Email. Less typing and more time to play with Exchange 2007!
Get-Mailbox | Format-List -Property Email*
Email
To learn more about Exchange 2007 and the Exchange Management Shell, see the following resources:
David Strome - Technical Writer, Microsoft Exchange Server