Depending on whom you ask, some experienced Exchange administrators will tell you that the Exchange Management Shell (EMS) is the best improvement that has been introduced for Exchange 2007. Is knowledge of the EMS required? Some administrators will manage their Exchange servers for years and rarely use the EMS, while others will use it daily. However, we think it is safe to say that at least limited knowledge of the EMS will be required by all administrators.
As we stated earlier in the chapter, the intent of the EMS was to provide a consistent interface for performing management tasks for Exchange 2007 servers, whether the tasks are automation tasks, writing scripts, or extending the management capabilities. Tasks or operations that once required multiple programming APIs and hundreds of lines of scripting can now be accomplished in a single command.
The Exchange Management Shell is a set of Exchange-specific extensions to the Windows PowerShell. In this section, we want to introduce you to the PowerShell as well as the EMS and to do so without overwhelming you. Introducing a concept like the PowerShell or the EMS in just a few pages is difficult, but we hope to give you a basic idea of some of the capabilities and encourage you to learn more.
In total, there are about 350 Exchange-related cmdlets that you can use in the EMS; the goal is to cover all Exchange-related administrative tasks. You will find cmdlets that manipulate other data in the Active Directory (such as cmdlets for managing user accounts) and manipulating Exchange-related data in the Registry or Internet Information Services, but the cmdlets will manipulate or manage only data related to Exchange. The Exchange team is expecting other internal Microsoft teams such as the Active Directory and Internet Information Server teams to provide their own extensions to the management shell.
The problem with a lot of scripting languages and command shells is that as they get more complex and powerful, the command syntax gets more and more cryptic. The Windows PowerShell and the EMS seek to make using the command-line interface and scripting more intuitive. To this end, most of the PowerShell and EMS cmdlets consist of two components, a verb and a noun.
The PowerShell cmdlets and the EMS extensions for the PowerShell are case not case sensitive. That means that you can type everything in uppercase, type everything in lowercase, or mix and match the case of the letters in your commands. For readability and per suggestions from folks on the Exchange team at Microsoft, we are using Pascal casing in this book. When you use Pascal casing, the first letter of each word is in uppercase, whether the cmdlet consists of one word or more than one word. All other letters in the cmdlet are in lowercase. So the cmdlet that is used to retrieve mailbox statistics is written as Get-MailboxStatistics. We are writing them this way merely for readability, though.
The verb identifies the action that is being taken and the noun indicates the object on which the action is being taken. The verb always comes first and the verb and noun are separated by a hyphen such as Get-Mailbox. Table 7.2 shows some of the common verbs that are found when using the EMS; some of these are specific to the EMS, but most are generic Windows PowerShell verbs.
Verb | Description |
---|---|
Get | Get is the probably the most common verb that you will use. Get retrieves information about the specified object and outputs information about the object. |
Set | Set is probably the second most common verb that you will use. Set allows you to update properties of the object specified in the noun. |
New | New creates new instances of the object specified in the noun. |
Enable | Enable activates or enables a configuration on the object specified, such as enabling an existing user account. |
Remove | Remove deletes an instance of the object specified in the noun. |
Disable | Disable disables or deactivates the object specified in the noun. An example of this is removing a mailbox from an existing user (but not deleting the user account). |
Mount | Mount is used to mount an Exchange 2007 mailbox or public folder database. |
Dismount | Dismount is used to dismount an Exchange 2007 mailbox or public folder database. |
Move | Move can be used to move mailboxes to other mailbox database. |
Test | Test performs diagnostics tests against the object specified by the noun and the identity option. |
The actual nouns that are used in conjunction with these verbs are too numerous to mention in even a few pages of text. Table 7.3 shows a list of some of the more common nouns; not to worry, though, later in this chapter we will show you how to use the online help to find more of the cmdlets that you need. The nouns in Table 7.3 can be used in conjunction with verbs such as the ones found in 7.2 to manipulate the properties of Exchange-related objects. Not all verbs work with all nouns, though.
Noun | Description |
---|---|
ActiveSyncMailboxPolicy | Properties of ActiveSync policies that can be assigned to mailbox |
CASMailbox | Properties of a mailbox relating to client features, such as OWA and MAPI properties |
ClientAccessServer | Properties specific to an Exchange Client Access server role |
DistributionGroup | Properties relating to mail-enabled distribution groups |
DynamicDistributionGroup | Properties relating to a dynamic distribution group |
EmailAddressPolicy | Properties relating to the policies that are used to define e-mail addresses |
ExchangeServer | Properties related to Exchange servers |
Mailbox | Properties related to user mailboxes |
MailboxDatabase | Properties related to mailbox databases |
MailboxServer | Properties specific to an Exchange Mailbox server role |
MailContact | Properties relating to mail-enabled contact objects |
MailPublicFolder | Properties relating to mail-enabled public folder objects |
MailUser | Properties related to a user that has an e-mail address but not a mailbox |
ReceiveConnector | Properties relating to Receive connectors |
SendConnector | Properties relating to Send connectors |
StorageGroup | Properties relating to storage groups |
TransportServer | Properties specific to an Exchange Hub Transport server role |
UMMailbox | Properties relating to Unified Messaging |
UMServer | Properties specific to an Exchange Unified Messaging server role |
User | Properties related to user objects |
One important thing to keep in mind with cmdlets is that they are not individual executables but rather .NET classes that are only accessible from within the PowerShell and only if the Exchange extensions to PowerShell are loaded.
For cmdlets that require input, usually the first parameter provided is the -Identity parameter. For example, if you want to retrieve information about a mailbox called Clayton Kamiya in the Corporate organizational unit (OU), you would type this:
Get-Mailbox -Identity 'fourthcoffee.com/Corporate/Clayton Kamiya'
However, you will quickly find that the identity parameter is not required. And, if your aliases or account names are unique, even the domain and organizational unit information is not required. For example, this command would yield the exact same results:
Get-Mailbox 'fourthcoffee.com/Corporate/Clayton Kamiya'
We can drop the domain and the OU name and as long as there is only one Clayton Kamiya in the Active Directory, this cmdlet will yield the exact same result:
Get-Mailbox 'Clayton Kamiya'
Tip | Anytime the identity you are using has a space in it, you must use quotes. Either single or double quotes will work as long as you are consistent. |
So the point is if you find that the identity parameter is not required, don't be concerned because it is by design. As you will find shortly, the input can even be piped in from another cmdlet's output.
If you are not sure what input can be specified for the identity parameter, you can easily look this information up either in the Exchange online help or using the EMS command-line help (more on this later in this chapter). For now, let's look at one small piece of the Get-Mailbox help screen:
-Identity <MailboxIdParameter> The Identity parameter identifies the mailbox. You can use one of the following values: * GUID * Distinguished name (DN) * Domain\Account * User principal name (UPN) * LegacyExchangeDN * SmtpAddress * Alias Required? false Position? 1 Default value Accept pipeline input? True Accept wildcard characters? True
From here, you can see that the identity parameter will take the mailbox GUID, the user's distinguished name, the domain name and account, the UPN name, the legacy Exchange distinguished name, the SMTP address, or the Exchange alias. And, of course you can pipe in input from the output of other cmdlets.
You will notice us sometimes using command and sometimes using cmdlet when talking about the PowerShell. There is a subtle difference. A cmdlet is the verb-noun combination that performs a specific task. For example, Get-Mailbox is a cmdlet. A complete command is the cmdlet along with any necessary options that the task might require. The command necessary to retrieve information about a specific mailbox looks like this:
Get-Mailbox "Mark Watts"
When we talk about generic Windows PowerShell functions such as Get-User or Get-Event, we refer to those as PowerShell functions. The Exchange Management Shell (EMS) is a series of extensions or additional functions that are added to PowerShell. These include functions such Get-Mailbox and Mount-Database that are specific to Exchange Server 2007. The Exchange Management Shell extensions always include the generic PowerShell functions.
A pretty common problem with new PowerShell and EMS users is that they open up the PowerShell and try to use Exchange specific cmdlets or use Exchange specific help. By default, the Exchange snap-ins are not loaded when you load the generic Windows PowerShell. You should run the Exchange Management Shell shortcut in the Microsoft Exchange Server 2007 start menu folder to get the correct EMS extensions.
However, from a generic Windows PowerShell command line on an machine that has the Exchange management tools installed, you can type Add-PSSnapin *exchange* and load the Exchange specific snap-ins.
PowerShell and EMS cmdlets also support a number of command-line parameters that are useful. Table 7.4 shows some of the parameters that cmdlets accept; not all cmdlets will accept all of these parameters - parameters are usually optional - and of course, some of these will not be relevant to some of the cmdlets you will use.
Parameter | Description |
---|---|
-Identity | Specifies a unique object on which the cmdlet is going to act. The Identity parameter is a positional parameter, which means that it does not necessarily have to be on the command line; PowerShell will prompt you for the identity if it is not specified. As we noted previously, in most cases you do not need to specify the -Identity parameter, just the unique object name. |
-Whatif | Tells the cmdlet to simulate the action that it would normally perform but not actually make the change. |
-Confirm | Asks the cmdlet to prompt for confirmation prior to starting the action. This option type is a Boolean, so you need to include either $True or $False. Some cmdlets (such as Move-Mailbox) do this by default, so you could specify -Confirm:$false if you did not want the confirmation to occur. |
-Validate | Validate will check the prerequisites of the cmdlet to verify that it will run correctly and let you know. |
-Credential | Allows you to specify alternate credentials when running a PowerShell command. |
s-DomainController | Allows you to specify the FQDN of a specific domain controller that you want to perform a PowerShell task against. |
-ResultSize | Allows you to specify a maximum number of results when working with Get- cmdlets. |
-SortBy | Allows you to specify a sorting criteria when outputting data that is usually the result of a Get- cmdlet. |
-Verbose | Instructs Get- cmdlets to return more information about their execution and possibly more data will be output. |
-Debug | Instructs the cmdlet to output more information and to proceed step-by-step through the process of performing a task. Debug returns more information that than a typical administrator needs to perform daily tasks. |
If you are piping output of one cmdlet in to another, the parameters must be within the cmdlet that you want them to affect.
In order to be descriptive and helpful, some of the cmdlets are actually pretty long. Consider if you had to type Get-DistributionGroupMember several times! However, the PowerShell includes a feature called tab completion. If you type part of a command and then press the Tab key, PowerShell will complete the cmdlet with the first matching cmdlet it can find. For example, if you type Get-Distri and press Tab, PowerShell will automatically fill out Get-DistributionGroup. If you press Tab again, PowerShell will move on to the next matching cmdlet, in this case Get-DistributionGroupMember.
The Tab completion feature also works for cmdlet parameters. If you type a cmdlet followed by a space and a hyphen, such as Get-Mailbox -, and then press Tab, you will cycle through all of the parameters for that particular cmdlet.
The PowerShell is even more flexible because the output of commands is not text based but rather object based. The PowerShell uses an object model that is based on the Microsoft .NET Framework. PowerShell cmdlets accept and return structured data. Don't let the terms object model and object oriented scare you, though. This is really quite simple. For example, Figure 7.25 shows the output of the Get-Mailbox cmdlet.
Figure 7.25: Output of the Get-Mailbox cmdlet
What you see on the screen is text, but to the PowerShell it is really a list of objects. You can manipulate the output to see the properties you want, filter the output, or pipe the output (the objects) to another cmdlet.
In Figure 7.25, you can see that the cmdlet we used (Get-Mailbox) output every mailbox in the entire organization. There are a number of ways that you can filter or narrow the scope of the output that are you looking for from a specific cmdlet. In the case of Get-Mailbox and other cmdlets, you can specify just the identity of the mailbox that you are looking for.
PowerShell includes two options that can be used specifically for filtering the output. These are the where and the filter clauses. The where clause can be used on most any cmdlet and filter is applied at the client. The filter clause is only available on a subset of the commands since the filter is applied by the server:
Get-Mailbox | where {$_.MaxSendSize -gt 25000000}
The output of the Get-Mailbox cmdlet is piped to the where clause that filters the output. In this case, the output is any mailbox whose MaxSendSize parameter is greater than 25000000 bytes. Did you notice $_.MaxSendSize the portion of the where statement? The $_portion represents the object that is being piped to the where clause, and the .MaxSendSize represents the MaxSendSize property of that object.
For nonprogrammers, this might seem a little difficult at first, but we promise it gets much easier as you go along. The operators are also simple to remember. Table 7.5 shows a list of common operators that can be used in clauses such as where.
Shell value | Operator | Function |
---|---|---|
-eq | Equals | The object.property value must match exactly the specified value. |
-ne | Not equals | The object.property value must not match the specified value. |
-gt | Greater than | The greater than works when the object.property value is an integer. |
-ge | Greater than or equal to | The greater than or equal to works when the object.property value is an integer. |
-lt | Less than | The less than works when the object.property value is an integer. |
-le | Less than or equal to | The less than or equal to works when the object.property value is an integer. |
-like | Contains | Contains is used when the object.property value is a text string. The matching string can either match exactly or contain wildcards (*) at the beginning or end. |
-notlike | Does not contain | Does not contain is used when the object.property value is a text string and you want to see if the values do not match the string. The matching string can contain wildcards (*) at the beginning or end. |
If you look at the output of the Get-Mailbox cmdlet shown in Figure 7.25, you might be tempted to think that the output capabilities of the PowerShell is limited, but this is far from the truth. The output shown in Figure 7.25 was the default output for the Get-Mailbox cmdlet. The programmer decided that the output should be in a formatted table with the name, alias, home server, and prohibit send quota properties as columns. However, you can select the properties you want by merely piping the output of the Get-Mailbox cmdlet to either the Format-Table (FT for short) or Select cmdlet. For example, in Figure 7.26, you can see that we used the following cmdlets:
Get-Mailbox | FT Name,ProhibitSendquota,ProhibitSendReceiveQuota
Figure 7.26: Outputting to a formatted table
The output of the Get-Mailbox cmdlet was directed to the Format-Table (or FT) cmdlet; the result was columns for the name, prohibit send, and prohibit send and receive quota limits.
You may be wondering how you can learn all of the properties of an object. The default output of the Get-Mailbox cmdlet, for example, is probably not the most useful for your organization. We will go into more detail on getting help in the PowerShell and Exchange Management Shell a bit later, but here is a simple trick to see all of the properties of an object: direct the output the results of a Get- cmdlet to the Format-List (FL for short) cmdlet instead of the default Format-Table output.
When you direct the output of a cmdlet such as Get-Mailbox to the Format-List cmdlet, you will see all of the properties for that object. Figure 7.27 shows an example where we have directed the output of a Get-Mailbox cmdlet to the FL (Format-List) cmdlet. The command we have used is Get-Mailbox ''Clayton Kamiya'' | Format-List.
Figure 7.27: Outputting to a formatted list
Outputting data to the screen is great, but it doesn't help you with reports. You can also output data to CSV and XML files. There are two cmdlets that make this easy to do; the Export-Csv and Export-Clixml cmdlets. Simply direct the output you want sent to a file and these cmdlets will take care of it. Let's use the same example we used previously, where we want a report of all mailboxes and their prohibit send and prohibit send and receive limits. However, we cannot use the Format-Table cmdlet in this instance. We have to use the Select-Object or just Select cmdlet to specify the output since we will be directing this to another cmdlet. Here is an example of the Get-Mailbox cmdlet when used with the Select command:
Get-Mailbox | Select Name, ProhibitSendQuota, ProhibitSendReceiveQuota
The output is shown here:
Name ProhibitSendQuota ProhibitSendReceiveQuota ---- ----------------- ------------------------ Missy Kosloksy unlimited unlimited Sueko Miura unlimited unlimited Daniel Petri unlimited unlimited Matt Paleafei unlimited unlimited Shawn Harbert 550000KB 575000KB William Lefkovics unlimited unlimited Dan Holme unlimited unlimited Todd Hawkins unlimited unlimited Karen Floyd unlimited unlimited Jason Serino unlimited unlimited
To direct this output to the C:\report.csv file, we simply pipe it to the Export-Csv cmdlet as shown here:
Get-Mailbox | Select Name, ProhibitSendQuota, ProhibitSendReceiveQuota | Export-CSV c:\report.csv
If you want to export the report to an XML file, simply use the Export-Xml cmdlet instead of Export-CSV.
Finally, just as when working with the DOS prompt, you can redirect output of a command to a text file. To send the output of Get-Mailbox to the file C:\mailboxes.txt, you would type this:
Get-Mailbox > c:\mailboxes.txt
You have already seen a couple of examples where we used the pipe symbol (|) to direct the output of one command to be the input of the next command, such as Get-Mailbox | FT. We can do this because the output of PowerShell commands consists of objects, not just text. Unlike with other shells or scripting languages, we don't have to use string commands or variables to pass data from one command to another. The result is that you can use a single line to perform a query and complex task, something that might have required hundreds of lines of programming in the past.
One of our favorite examples would be making specific changes to a group of people's mailboxes. Let's say that we need to ensure that all executives in our organization are able to send and receive a message that up to 50MB in size rather than the default 10MB. Earlier we showed you how you could get the properties of the mailbox that you were interested in, such as the MaxSendSize and MaxReceiveSize properties.
First, let's use the Get-DistributionGroupMember cmdlet to retrieve the members of the Executives distribution group. Here are the results of typing Get-DistributionGroupMember ''executives'':
Get-DistributionGroupMember "executives" Name RecipientType ---- ------------- Mark Watts MailboxUser David Elfassy MailboxUser Brian Tirch MailboxUser Paul Robichaux MailboxUser Devin Ganger MailboxUser Julie Samante MailboxUser Todd Hawkins MailboxUser
Remember that while we see the text listing of the group members, what is actually output are objects representing each of the members. Now let's pipe the output of that cmdlet to the Set-Mailbox cmdlet and do some real work! To change the maximum incoming and outgoing message size for the members of the Executives group, we would type this:
Get-DistributionGroupMember "executives" | Set-Mailbox -MaxSendSize:50MB -MaxReceiveSize:50MB
Notice that the Set-Mailbox cmdlet did not require any input since it will take as input the objects that are output from Get-DistributionGroupMember. When you run these two commands, there will be no output unless you have specified other options. But, you can easily check the results by requesting the membership of the Executives group, pipe that to the Get-Mailbox cmdlet, and then pipe that output to the Format-Table cmdlet:
Get-DistributionGroupMember "Executives" | Get-Mailbox | FT Name,MaxSendSize,MaxReceiveSize Name MaxSendSize MaxReceiveSize ---- ----------- -------------- Mark Watts 50MB 50MB David Elfassy 50MB 50MB Brian Tirch 50MB 50MB Paul Robichaux 50MB 50MB Devin Ganger 50MB 50MB Julie Samante 50MB 50MB Todd Hawkins 50MB 50MB
Pretty cool, eh? After just a few minutes working with the PowerShell and the EMS extensions, we hope that you will be as pleased with their ease of use as we are. We will leave you with one more example of piping and hopefully this will be an example that you can use in the future. We will do a report of the mailbox statistics using the Get-MailboxStatistics cmdlet and will narrow the focus of the output so that the system mailboxes are not included. We will limit the output by using the Where command clause, choose the properties to output using the Select command, and finally pipe that output to the Export-Csv cmdlet:
Get-MailboxStatistics | Where {$_.DisplayName -notlike "System*"}| Select DisplayName,ItemCount, TotalItemSize,StorageLimitStatus | Export-Csv c:\StorStats.csv
We have shown you a few simple yet powerful examples of how to use the PowerShell and the EMS. Once you dig in and start using the EMS, you will need some references to help you figure out all of the syntax and properties of each of the cmdlets. A great starting place for just reading about the cmdlets is in the Microsoft Exchange Server 2007 help file. The help file documents how to do most common operations both through the graphical user interface and through the EMS. Figure 7.28 shows the online help for how to create a new mailbox. After the procedures for creating the mailbox through the GUI are shown, you will see the procedures for using the EMS.
Figure 7.28: Referring to the online help for creating a new mailbox
After the example that is shown for creating the mailbox, you see a link to the New-Mailbox cmdlet that will take you to much more detailed information on that specific cmdlet. The New-Mailbox help topic (shown in Figure 7.29) will provide you with a great amount of detail about the use of the cmdlet. We strongly recommend you take advantage of the Exchange help file that is included with Exchange Server. In fact, you might want to even copy the file and save it to your workstation. The filename is ExchHelp.chm.
Figure 7.29: Online help for creating a new mailbox using the Exchange Management Shell
Information is also available on the cmdlets from within the PowerShell. For a good starting point, you can just type the help command and this will give you a good overview of using the PowerShell and how to get more help. Table 7.6 shows a list of some common methods of getting help on PowerShell and Exchange Management Shell cmdlets.
Action | Description |
---|---|
Help | Provides generic PowerShell help information. |
Help *keyword* | Lists all cmdlets that contain the keyword. For example, if you want to find all cmdlets that work with mailboxes, you would type help *mailbox*. |
Get-Command *keyword* | Lists all cmdlets and files (such as help files) that contain the keyword. |
Get-Command | Lists all cmdlets (including all PowerShell extensions currently loaded such as the EMS cmdlets). |
Get-Excommand | Lists all Exchange cmdlets. |
Get-PSommand | Lists all PowerShell cmdlets. |
Help cmdlet or Get-Help cmdlet | List online help for the specified cmdlet and pauses between each screen. Provide multiple views of the online help (such as detailed, full, examples, and default). |
Cmdlet -? | Lists online help for the specified cmdlet. |
When you're working with help within the PowerShell, help topics are displayed based on the view of help that you request. In other words, you can't just type Get-Help CmdletName and see everything about the specified cmdlet. The Get-Help cmdlet includes four possible views of help for each cmdlet. Table 7.7 explains the four primary views plus the parameters view.
View Option | Explanation |
---|---|
Default | The default view lists the minimum amount of information to describe the function of the cmdlet and show its syntax. |
Example | The example view includes a synopsis of the cmdlet and some examples of its usage. |
Detailed | The detailed view shows more details on a cmdlet, including parameters and parameter descriptions. |
Full | The full view shows all the details available on a cmdlet, including a synopsis of the cmdlet, a detailed description, parameter descriptions, parameter metadata, and examples. |
Parameters | The parameters view allows you to specify a parameter and get help on the usage of just that particular parameter. |
The full option for Get-Help includes in its output each parameter's metadata:
Required? | Is the parameter required? This is either true or false |
Position? | Specifies the position of the parameter. If the position is "named," then the parameter name has to be included in the parameter list. Most parameters are named parameters. However, the Identity parameter is "1," which means that it is always the first parameter and the -Identity tag is not required. |
Default value | For most parameters this is blank, but it specifies what a value will be for a parameter if nothing else is specified. |
Accept Pipeline Input? | Specifies if the parameter will accept input that is piped in from another cmdlet. The value is either true or false. |
Accept wildcard characters? | Specifies if the parameter accepts wildcard characters such as the asterisk or question mark. This is either true or false. |
Still not clear about what each view gives you? Perhaps Table 7.8 can shed some further light on the issue. This table shows you the different sections that are output when using each view option.
Default View | Example View | Detailed View | Full View | |
---|---|---|---|---|
Synopsis | ü | ü | ü | ü |
Detailed description | ü | ü | ü | |
Syntax | ü | ü | ü | |
Parameters | ü | ü | ||
Parameter metadata | ü | |||
Input type | ü | |||
Return type | ü | |||
Errors | ü | |||
Notes | ü | |||
Examples | ü | ü | ü |
To use these parameters, you type would use the following Get-Help cmdlet by the view option. For example, to see the example view for Get-Mailbox, you would type this:
Get-Help Get-Mailbox -Example
Let's look at a couple of more detailed examples for the Get-MailboxStatistics cmdlet. We are choosing a cmdlet (Get-MailboxStatistics) that we feel is pretty representative of the EMS cmdlets but also does not have a huge amount of help information. We feel it is important for administrators to understand the available online help options. First, let's look at the default view. We can type just Get-Help Get-MailboxStatistics, the -Default option is not necessary:
Get-Help Get-MailboxStatistics -Default NAME Get-MailboxStatistics SYNOPSIS Use the Get-MailboxStatistics cmdlet to obtain information about a mailbox, such as the size of the mailbox, the number of messages it contains, and the last time it was accessed. SYNTAX Get-MailboxStatistics [-Identity <GeneralMailboxIdParameter>] [- DomainController <Fqdn>] [<CommonParameters> ] Get-MailboxStatistics -Database <DatabaseIdParameter> [-DomainController <Fqdn>] [<CommonParameters>] Get-MailboxStatistics -Server <ServerIdParameter> [-DomainController <Fqdn>] [<CommonParameters>] DETAILED DESCRIPTION To run the Get-MailboxStatistics cmdlet on a computer that has any server role installed, except the Edge Transport server role, you must log on by using a domain account that has the permissions assigned to the Exchange Server Administrators group. The account must also be a member of the local Administrators group on that computer. On Mailbox servers only, you can use the Get-MailboxStatistics cmdlet without parameters. In this case, the cmdlet will return the statistics for all mailboxes on all databases on the local server. RELATED LINKS REMARKS For more information, type: "get-help Get-MailboxStatistics - detailed". For technical information, type: "get-help Get-MailboxStatistics - full".
This view (as you could have predicted from Table 7.8) includes the synopsis, syntax, and detailed description sections. Let's change our approach and look at the example view:
Get-Help Get-MailboxStatistics -Examples NAME Get-MailboxStatistics SYNOPSIS Use the Get-MailboxStatistics cmdlet to obtain information about a mailbox, such as the size of the mailbox, the number of messages it contains, and the last time it was accessed. Get-MailboxStatistics Get-MailboxStatistics -Server MailboxServer01 Get-MailboxStatistics -Identity contoso\chris Get-MailboxStatistics -Database "Mailbox Database" Get-MailboxStatistics | Where {$_.DisconnectDate -ne $null}
The example view does not have as much data, but a lot of techies learn by looking at examples, so we find this view particularly useful. Next let's look at the detailed view; since this view includes the parameters, it will have quite a bit more information:
Get-Help Get-MailboxStatistics -Detailed NAME Get-MailboxStatistics SYNOPSIS Use the Get-MailboxStatistics cmdlet to obtain information about a mailbox, such as the size of the mailbox, the number of messages it contains, and the last time it was accessed. SYNTAX Get-MailboxStatistics [-Identity <GeneralMailboxIdParameter>] [-DomainController <Fqdn>] [<CommonParameters>] Get-MailboxStatistics -Database <DatabaseIdParameter> [-DomainController <Fqdn>] [<CommonParameters>] Get-MailboxStatistics -Server <ServerIdParameter> [-DomainController <Fqdn>] [<CommonParameters>] DETAILED DESCRIPTION To run the Get-MailboxStatistics cmdlet on a computer that has any server role installed, except the Edge Transport server role, you must log on by using a domain account that has the permissions assigned to the Exchange Serv Administrators group. The account must also be a member of the local Administrators group on that computer. On Mailbox servers only, you can use the Get-MailboxStatistics cmdlet without parameters. In this case, the cmdlet will return the statistics for all mailboxes on all databases on the local server. PARAMETERS -Database <DatabaseIdParameter> The Database parameter specifies the name of the mailbox database. When you specify a value for the Database parameter, the Exchange Management Shell returns statistics for all the mailboxes on the database specified. You can use the following values: * Server\StorageGroup\Database * Server\Database * Database This parameter accepts pipeline input from the Get- MailboxDatabase cmdlet. -Server <ServerIdParameter> The Server parameter specifies the server from which you want to obtain mailbox statistics. You can use one of the following values: * Fully qualified domain name (FQDN) * NetBIOS name When you specify a value for the Server parameter, the command returns statistics for all the mailboxes on all the databases, including recovery databases, on the specified server. If you do not specify this parameter, the command returns logon statistics for the local server. This parameter accepts pipeline input from the Get- ExchangeServer and Get-MailboxServer cmdlets. -DomainController <Fqdn> To specify the fully qualified domain name (FQDN) of the domain controller that retrieves data from the Active Directory directory service, include the DomainController parameter in the command. -Identity <GeneralMailboxIdParameter> The Identity parameter specifies a mailbox. When you specify a value for the Identity parameter, the command looks up the mailbox that is specified in the Identity parameter, connects to the server where the mailbox resides, and returns the statistics for the mailbox. You can use one of the following values: * GUID * Distinguished name (DN) * Domain\Account * User principal name (UPN) * Legacy Exchange DN * SmtpAddress * Alias This parameter accepts pipeline input from the Get-Mailbox cmdlet. <CommonParameters> This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information,type, "get-help about commonparameters". Get-MailboxStatistics Get-MailboxStatistics -Server MailboxServer01 Get-MailboxStatistics -Identity contoso\chris Get-MailboxStatistics -Database "Mailbox Database" Get-MailboxStatistics | Where {$_.DisconnectDate -ne $null} REMARKS For more information, type: "get-help Get-MailboxStatistics - detailed". For technical information, type: "get-help Get-MailboxStatistics - full".
Naturally, the full view is going to contain a little bit more information than the detailed view. The full view includes the metadata for each parameter as well as examples:
Get-Help Get-MailboxStatistics -Full NAME Get-MailboxStatistics SYNOPSIS Use the Get-MailboxStatistics cmdlet to obtain information about a mailbox, such as the size of the mailbox, the number of messages it contains, and the last time it was accessed. SYNTAX Get-MailboxStatistics [-Identity <GeneralMailboxIdParameter>] [-DomainController <Fqdn>] [<CommonParameters>] Get-MailboxStatistics -Database <DatabaseIdParameter> [-DomainController <Fqdn>] [<CommonParameters>] Get-MailboxStatistics -Server <ServerIdParameter> [- DomainController <Fqdn>] [<CommonParameters>] DETAILED DESCRIPTION To run the Get-MailboxStatistics cmdlet on a computer that has any server role installed, except the Edge Transport server role, you must log on by using a domain account that has the permissions assigned to the Exchange Server Administrators group. The account must also be a member of the local Administrators group on that computer. On Mailbox servers only, you can use the Get-MailboxStatistics cmdlet without parameters. In this case, the cmdlet will return the statistics for all mailboxes on all databases on the local server. PARAMETERS -Database <DatabaseIdParameter> The Database parameter specifies the name of the mailbox database. When you specify a value for the Database parameter, the Exchange Management Shell returns statistics for all the mailboxes on the database specified. You can use the following values: * Server\StorageGroup\Database * Server\Database * Database This parameter accepts pipeline input from the Get- MailboxDatabase cmdlet. Required? true Position? Named Default value Accept pipeline input? True Accept wildcard characters? false -Server <ServerIdParameter> The Server parameter specifies the server from which you want to obtain mailbox statistics. You can use one of the following values: * Fully qualified domain name (FQDN) * NetBIOS name When you specify a value for the Server parameter, the command returns statistics for all the mailboxes on all the databases, including recovery databases, on the specified server. If you do not specify this parameter, the command returns logon statistics for the local server. This parameter accepts pipeline input from the Get- ExchangeServer and Get-MailboxServer cmdlets. Required? true Position? Named Default value Accept pipeline input? True Accept wildcard characters? false -DomainController <Fqdn> To specify the fully qualified domain name (FQDN) of the domain controller that retrieves data from the Active Directory directory service, include the DomainController parameter in the command. Required? false Position? Named Default value Accept pipeline input? False Accept wildcard characters? false -Identity <GeneralMailboxIdParameter> The Identity parameter specifies a mailbox. When you specify a value for the Identity parameter, the command looks up the mailbox that is specified in the Identity parameter, connects to the server where the mailbox resides, and returns the statistics for the mailbox. You can use one of the following values: * GUID * Distinguished name (DN) * Domain\Account * User principal name (UPN) * Legacy Exchange DN * SmtpAddress * Alias This parameter accepts pipeline input from the Get-Mailbox cmdlet. Required? false Position? 1 Default value Accept pipeline input? True Accept wildcard characters? false <CommonParameters> This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about commonparameters". INPUT TYPE RETURN TYPE TERMINATING ERRORS (Category: ) Type: Target Object Type: Suggested Action: NON-TERMINATING ERRORS (Category: ) Type: Target Object Type: Suggested Action: Get-MailboxStatistics Get-MailboxStatistics -Server MailboxServer01 Get-MailboxStatistics -Identity contoso\chris Get-MailboxStatistics -Database "Mailbox Database" Get-MailboxStatistics | Where {$_.DisconnectDate -ne $null} RELATED LINKS
Yes, that is a lot of text for examples of one cmdlet, but we hope that these examples will make it easier for you to quickly learn the capabilities of all cmdlets and how you can use them.
The EMS help system also gives you some options with respect to getting help on parameters. For example, here is an example if you want help on just the -Database parameter of the Get-MailboxStatistics cmdlet:
Get-Help Get-MailboxStatistics -Parameter Database -Database <DatabaseIdParameter> The Database parameter specifies the name of the mailbox database. When you specify a value for the Database parameter, the Exchange Management Shell returns statistics for all the mailboxes on the database specified. You can use the following values: * Server\StorageGroup\Database * Server\Database * Database This parameter accepts pipeline input from the Get-MailboxDatabase cmdlet. Required? true Position? Named Default value Accept pipeline input? True Accept wildcard characters? false
The parameters option also accepts the asterisk (*) wildcard. Here is an example where we want to see help on all of the parameters that contain SCLQuarantine:
Get-Help Set-Mailbox -Parameter *SCLQuarantine* -SCLQuarantineEnabled <Nullable> The SCLQuarantineEnabled parameter specifies whether messages that meet the spam confidence level threshold specified by the SCLQuarantineThreshold parameter will be quarantined. If a message is quarantined, it is sent to the quarantine mailbox where the messaging administrator can review it. You can use the following values: * $true * $false * $null Required? false Position? Named Default value Null Accept pipeline input? False Accept wildcard characters? false -SCLQuarantineThreshold <Nullable> The SCLQuarantineThreshold parameter specifies the spam confidence level at which a message will be quarantined, if the SCLQuarantineEnabled parameteris set to $true. You must specify an integer between 0 and 9 inclusive. Required? false Position? Named Default value Null Accept pipeline input? False Accept wildcard characters? false