The
Exchange Management Shell shares the same verb-noun syntax as
PowerShell. This provides a consistent set of commands to learn and
understand within the command environment.
Understanding the Verb-Noun Construct
EMS
uses a strict verb-noun naming construct for all of its cmdlets. The
verb is separated from the noun with a hyphen. For example, the cmdlet get-mailbox returns all of the mailbox objects in the organization.
The verbs used in both EMS and PowerShell are listed in Table 1.
There is a high level of verb reuse to provide a consistent,
predictable user experience. As in the English language, there are many
more nouns than verbs. Examples of nouns used in EMS are mailbox,
Mailboxserver, ExchangeServer, TransportSettings,
DatabaseAvailabilityGroup, object, service, and so on.
Table 1. PowerShell and EMS Verbs
Add | Backup | Invoke |
Clear | Checkpoint | Register |
Close | Compare | Request |
Copy | Compress | Restart |
Enter | Convert | Resume |
Exit | ConvertFrom | Start |
Find | ConvertTo | Stop |
Format | Dismount | Submit |
Get | Edit | Suspend |
Hide | Expand | Uninstall |
Join | Export | Unregister |
Lock | Group | Wait |
Move | Import | Debug |
New | Initialize | Measure |
Open | Limit | Ping |
Pop | Merge | Repair |
Push | Mount | Resolve |
Redo | Out | Test |
Remove | Publish | Trace |
Rename | Restore | Connect |
Reset | Save | Disconnect |
Search | Sync | Read |
Select | Unpublish | Receive |
Set | Update | Send |
Show | Approve | Write |
Skip | Assert | Block |
Split | Complete | Grant |
Step | Confirm | Protect |
Switch | Deny | Revoke |
Undo | Disable | Unblock |
Unlock | Enable | Unprotect |
Watch | Install | Use |
Walking Through Cmdlets in EMS
Some
cmdlets offer many different switches and parameters. If administrators
are not comfortable entering all the parameters for a cmdlet in one
line, they can enter as much as they want, press Enter, and EMS prompts
for the rest. This provides an easy way to run cmdlets that are not
often used and that don’t necessarily need to be saved for reuse.
For example, enter Dismount-Database and EMS prompts for the missing required parameters:
cmdlet Dismount-Database at command pipeline position 1
Supply values for the following parameters:
Identity: MBDB14
Confirm
Are you sure you want to perform this action?
Dismounting database "MBDB14". This may result in reduced availability for mail-
boxes in the database.
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): y
This is the same as entering the following single line at the EMS command line:
Getting Help with EMS
The Exchange Management
Shell features a QuickRef guide that gives a quick tutorial on common
commands and syntax. It provides common tasks and options, tips and
tricks, recipient management examples, storage management examples,
transport configuration examples,
policy configuration, and server management examples. This is presented
in a Hypertext Markup Language (HTML) page by simply typing QuickRef at the EMS console on the Exchange server.
The Exchange
Management Shell includes two basic types of help—command help and
conceptual help. Both types can be accessed from the console using the Get-Help cmdlet, which also uses the alias help.
To retrieve a list of all available help topics, simply type help *. To get help with a specific cmdlet, type help cmdlet-name. For example, help move-databasepath displays the purpose of the cmdlet, all the required and optional parameters, return variables, and examples of its use.
By default, some
information appears in the console window as one long, scrolling topic.
To view the information a single page at a time, pipe the results to more. For example, Get-ExCommand | More displays all the Exchange Server–specific cmdlets available in EMS, one page at a time.
Using Pipelining in EMS
Pipelining is the key to the power of EMS. It uses the output of one cmdlet to run through another cmdlet using the | (pipeline) operator. Pipelining provides bulk management changes. To understand this concept, examine this example:
Get-mailbox –server MBX1 | set-mailbox -MaxSendSize 5mb
The first part of the line, the part before the |
pipeline operator, tells EMS to get all the mailbox objects on mailbox
server MBX1. It then sends, or pipelines, the resulting set of objects
to the next command, which instructs it to set the maximum send size of
an email for these users to 5MB.
Another way of saying it is that one process output is consumed by another and another. Consider another example:
get-mailbox | where-object { $_.name -like "amy*" } | set-Mailbox -MaxSendSize 10mb
In this example, the get-mailbox cmdlet returns all the mailbox objects on all servers in the organization. This collection of objects is piped through the where-objectamy. The $_ variable equates to “this object.” The resulting set of objects, in turn, is piped through the set-Mailbox cmdlet to pass the parameter –MaxSendSize and set the value to 10MB. filter cmdlet that filters the mailbox objects to include only mailboxes with names beginning with
Note that EMS is not case-sensitive and that it understands that 10MB equates to 10,240,000 bytes. In this example, the get-mailbox cmdlet produces a result, the where-object consumes it and produces another result, and this result is consumed by the set-mailbox cmdlet to set the new value.
Using the WhatIf Switch and Confirm Parameter
There
are times when the administrator writes a simple or complicated script
in EMS and wonders what results it will produce. Some cmdlets support
the –WhatIf–Confirm parameter. The –WhatIf switch informs the administrator what action the script would take if executed without the -WhatIf switch, and the –Confirm parameter prompts for confirmation before taking action. switch and
For example, suppose the
administrator wants to set the Archive Warning Quota for all mailboxes
in the Mailbox Store 5 database on server SERVER1. The administrator
could use the following command:
Get-mailbox –database "SERVER1\Mailbox Store 5" | set-mailbox
–ArchiveWarningQuota 2GB
By adding the –WhatIf switch, the following sample result is output to the console for each mailbox:
What if: Setting mailbox "companyabc.com/Admins/Keith Johnson"
What if: Setting mailbox "companyabc.com/Users/Jason Guillet"
This enables the
administrator to easily see all the mailboxes that the set operation
would be performed on by the script. If the results are as expected, the
administrator presses the up arrow to recall the last typed line, and
removes the –WhatIf switch to execute the script.
If the administrator adds the –Confirm parameter, the following is output to the console:
Confirm
Are you sure you want to perform this action?
Setting mailbox "companyabc.com/Admins/Keith Johnson".
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help
(default is "Y"):
Entering Y processes this operation, A processes all operations, N skips this operation, and L cancels further processing.