Microsoft Exchange Server 2007 Administrators Pocket Consultant Second Edition
Exchange Management Shell is a command-line management interface built on the Windows PowerShell. You use Exchange Management Shell to manage any aspect of Exchange Server 2007 configuration that you can manage in the Exchange Management Console. This means that you can typically use either tool to configure Exchange Server 2007. However, there are also some configuration settings that you can manage only by using Exchange Management Shell.
Running and Using Exchange Management Shell
After you've installed the Exchange management tools on a computer, you can start the Exchange Management Shell by clicking Start, pointing to All Programs, selecting Microsoft Exchange Server 2007, and then selecting Exchange Management Shell. You know you are using the Exchange Management Shell because the command prompt title bar shows "Machine:" followed by the server name and the current working directory. The current path is preceded by [MSH], as shown in Figure 6-2.
When you start the Exchange Management Shell, it is initialized by a Microsoft Configuration (MCF1) file that instructs the shell to use administrator mode and obtain specific session settings about the Active Directory environment in which Exchange Server is being used. Because Exchange Management Shell is an extension of the Windows PowerShell, user and system profiles are also run to set up the environment. If you want to use specific environment settings every time you use Exchange Management Shell, you should put the settings in your user profile-either %User-Profile%∖My Documents∖PSConfiguration∖profile.ps1 or %UserProfile%∖My Doc-uments∖PSH∖Microsoft.PowerShell_profile.ps1.
When you work with Exchange Management Shell, all the Windows PowerShell cmdlets and aliases are available for your use. Although additional cmdlets are added, no additional aliases are added to the working environment. To end your session, you can exit the Exchange Management Shell and go to the command prompt by typing exit. Or you can close the shell window by clicking Close.
Working with Exchange Cmdlets
When you are working with the Exchange Management Shell, additional Exchange-specific cmdlets are available. As with Windows PowerShell cmdlets, you can get help information on Exchange cmdlets:
-
To view a list of all Exchange cmdlets, type get-excommand at the shell prompt.
-
To view Exchange cmdlets related to a specific server role, type get-help –role
RoleName where RoleName is the name of the server role you want to examine. Role names you can use are:
-
q *UM* for cmdlets related to the Unified Messaging Server role
-
q *Mailbox* for cmdlets related to the Mailbox Server role
-
q *ClientAccess* for cmdlets related to the Client Access Server role
-
When you work with Exchange Management Shell, you'll often work with Get-, Set-, Enable-, Disable-, New-, and Remove-cmdlets. These cmdlets all accept the -Identity parameter, which identifies the unique object with which you are working.
Typically, a cmdlet that accepts the -Identity parameter has it as its first parameter, allowing you to specify the identity, with or without the parameter name. When identities have names as well as aliases, you can specify either value as the identity. For example, you can use any of the following techniques to retrieve the mailbox object for the user William Stanek with the mail alias WilliamS:
get-mailbox -identity Williams
get-mailbox -identity ‘William Stanek’
get-mailbox Williams
get-mailbox "William Stanek"
With Get-cmdlets, you typically can return an object set containing all related items simply by omitting the identity. For example, if you type get-mailbox at the shell prompt without specifying an identity, you get a list of all mailboxes in the enterprise (up to the maximum permitted to return in a single object set).
Working with Object Sets and Redirecting Output
When you are working with Exchange Management Shell, you'll often need to redirect the output of one cmdlet and pass it as input to another cmdlet. You can do this using the pipe (¦) symbol. For example, if you want to view mailboxes for a specific mailbox database rather than all mailboxes in the enterprise, you can pipe the output of get-mailboxdatabase to get-mailbox, as shown in this example:
get-mailboxdatabase -Identity "Engineering" ¦ get-mailbox
Here, you use get-mailboxdatabase to get the mailbox database object for the Engineering database. You then send this object to the get-mailbox cmdlet as input, and get-mailbox iterates through all the mailboxes in this database. If you don't perform any other manipulation, the mailboxes for this database are listed as output, as shown here:
Name | Alias | Server | ProhibitSendQuota |
Administrator | Administrator | corpsvr127 | unlimited |
William S | williams | corpsvr127 | unlimited |
Tom G | tomg | corpsvr127 | unlimited |
David W | davidw | corpsvr127 | unlimited |
Kari F | karif | corpsvr127 | unlimited |
Connie V | conniev | corpsvr127 | unlimited |
Mike D | miked | corpsvr127 | unlimited |
You could also pipe this output to another cmdlet to perform an action on each individual mailbox in this database.
Категории