Applies to: Exchange Server 2013

Topic Last Modified: 2012-10-01

This topic explains how to read the Exchange Management Shell parameter sets and examples in the Exchange Help documentation and how to format a command so that the Shell can process the command. In the Shell and the Microsoft Exchange Server 2013 Help, parameter sets are displayed in the Syntax section of a cmdlet Help topic. For more information about cmdlet help, see Getting Help.

Contents

Command conventions in the Exchange Management Shell

Parameter sets

Use of quotation marks

Command operators in the Exchange Management Shell

Command conventions in the Exchange Management Shell

The Shell follows several command conventions that help you understand what information is required or optional when you run a command and how you must present the parameters and their values. See the "Parameter sets" section later in this topic for examples of how parameter sets are presented in the Shell Help and Exchange 2013 Help.

The following table lists these command conventions.

Exchange Management Shell command conventions

Symbol Description

-

A hyphen indicates that the next word on the command line is a parameter. The most common parameter is Identity. For more information, see Parameters.

< >

Angle brackets are used to enclose parameter values. These values can be choices or names. For example, in -Parameter1 <1 | 2 | 3>, the numbers represent specific value choices. In -Parameter2 <ServerName>, ServerName represents the actual value.

[ ]

Square brackets are used to enclose an optional parameter and its value. A parameter and its value that are not enclosed in square brackets are required.

|

When the pipe symbol is used in a parameter value list, such as -Parameter1 <1 | 2 | 3>, it indicates a choice between available values. This convention applies to System.Enum parameters and System.Boolean parameters.

These command conventions help you understand how a command should be constructed. Don't type these conventions when you enter the command on the command line.

Parameter sets

In the Exchange Help documentation, all cmdlets display their associated parameters in parameter sets. Parameter sets are groupings of parameters that can be used with each other. Parameters that exist in one parameter set, but not in another parameter set, are mutually exclusive. They can't be used together.

Although all cmdlets have parameter sets, many only have one set of parameters. This means that all the parameters on that cmdlet can be used with each other. Other cmdlets may have several parameter sets. The following example displays the parameter sets that are available on the New-SystemMessage cmdlet:

Copy Code
New-SystemMessage -DsnCode <EnhancedStatusCode> -Internal <$true | $false> -Language <CultureInfo> -Text <String> <COMMON PARAMETERS> 
 
New-SystemMessage -Language <CultureInfo> -QuotaMessageType <WarningMailboxUnlimitedSize | WarningPublicFolderUnlimitedSize | WarningMailbox | WarningPublicFolder | ProhibitSendMailbox | ProhibitPostPublicFolder | ProhibitSendReceiveMailBox> -Text <String> <COMMON PARAMETERS> 
 
COMMON PARAMETERS: [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-WhatIf [<SwitchParameter>]]

The New-SystemMessage cmdlet has two parameter sets (plus the COMMON PARAMETERS list; more on that later). The first parameter set contains the DsnCode parameter and Internal parameter, and the second parameter set contains the QuotaMessageType parameter. This means that the DsnCode parameter and Internal parameter can be used with each other. But, they can't be used with the QuotaMessageType parameter.

Parameter sets can indicate that a single cmdlet may have multiple uses. For example, you can use the New-SystemMessage cmdlet to configure customized delivery status notification (DSN) messages or configure customized mailbox quota limit messages. However, cmdlets typically have multiple parameter sets because one parameter may perform a function that is incompatible with another parameter. For example, the following example displays the parameter sets for the Set-ManagementScope cmdlet:

Copy Code
Set-ManagementScope [-RecipientRestrictionFilter <String>] [-RecipientRoot <OrganizationalUnitIdParameter>] <COMMON PARAMETERS> 

Set-ManagementScope -ServerRestrictionFilter <String> <COMMON PARAMETERS> 

Set-ManagementScope -DatabaseRestrictionFilter <String> <COMMON PARAMETERS> 

Set-ManagementScope -PartnerDelegatedTenantRestrictionFilter <String> <COMMON PARAMETERS> 

COMMON PARAMETERS: -Identity <ManagementScopeIdParameter> [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-Force <SwitchParameter>] [-Name <String>] [-WhatIf [<SwitchParameter>]]

In the Set-ManagementScope cmdlet, the first parameter set lists the parameters that let you create a recipient filter-based management scope. The subsequent parameter sets let you create server and database scopes respectively (partner scopes are a Microsoft internal-only scope and are not publically available). Only the parameters that are listed in each parameter set can be used with each other. For example, you can’t use the RecipientRestrictionFilter parameter with the DatabaseRestrictionFilter parameter in the same command because they’re in different parameter sets.

However, you’ll notice that each parameter set includes <COMMON PARAMETERS>. Common parameters can be used with parameters in any parameter set. The list of common parameters is included at the end of all the available parameter sets and begins with COMMON PARAMETERS:. You can, for example, use the Identity parameter in a command with the RecipientRestrictionFilter parameter and in another command with the ServerRestrictionFilter parameter, or any other parameter.

Use of quotation marks

Double quotation marks ( " ) are most commonly used to enclose a value that has spaces when you pass that value to a parameter. For example, if you want to pass Contoso Receive Connector to the Name parameter of the Set-ReceiveConnector cmdlet, you must enclose Contoso Receive Connector in quotation marks as in the following example:

Copy Code
Set-ReceiveConnector -Name "Contoso Receive Connector"

If you don't enclose the string in quotation marks, the Shell tries to interpret each word in the string as a new argument on the command line and displays an error.

In the Shell, double quotation marks and single quotation marks ( ' ) have different meanings. When you enclose a string in double quotation marks, the Shell replaces any variables with a matching value. For example, assume the value ServerName is assigned to the variable $Server. Then, assume the following command is entered on the command line:

Copy Code
"$Server Example"

The following output is displayed:

Copy Code
ServerName Example

The variable $Server is replaced by the value ServerName in the output.

When you enclose a string in single quotation marks, the Shell doesn't try to replace variables with a matching value. Assume the variable $Server is still assigned the value ServerName. Then assume the following command is entered on the command line:

Copy Code
'$Server-Example'

The following output is displayed:

Copy Code
$Server-Example

The variable $Server has not been replaced with a value because the Shell doesn't interpret variables that are included in text that is enclosed in single quotation marks.

For more information about variables, see User-Defined Variables and Shell Variables.

Escape character

You may also want to display some characters, such as the dollar sign ( ), double or single quotation marks, or back quotation mark ( ). These characters have special meanings when you use them in the Shell. To instruct the Shell not to interpret these characters and to display them when they are included in a string that is enclosed with double quotation marks, you must use the back quotation mark escape character ( ` ). For example, type the following text on the command line:

Copy Code
"The price is `$23."

The following output is displayed:

Copy Code
The price is $23.

Because we used the back quotation escape character with the dollar sign ( ), the Shell doesn't interpret the $ as the beginning of a variable.

If you enclose a string in single quotation marks, you don't have to escape any character unless you want to display a single quotation mark in a string. If you want to display a single quotation mark in a string that is enclosed in single quotation marks, you must use two single quotation marks ( '' ). For example, type the following on the command line:

Copy Code
'Don''t confuse two single quotation marks with a double quotation mark!'

The following output is displayed:

Copy Code
Don't confuse two single quotation marks with a double quotation mark!

Command operators in the Exchange Management Shell

Use the operators in the following table when you type commands in the Shell. Some of the operators may match some of the previously mentioned command conventions. However, they don't have the same meaning when they are typed on the command line. The following table shows the valid operators that you can use in a command.

Exchange Management Shell command operators

Operator Description

=

The equal sign is used as an assignment character. The value on the right side of the equal sign is assigned to the variable on the left side of the equal sign. The following characters are also assignment characters:

  • +=   Add the value on the right side of the equal sign to the current value that is contained in the variable on the left side of the equal sign.

  • -=   Subtract the value on the right side of the equal sign from the current value that is contained in the variable on the left side of the equal sign.

  • *=   Multiply the current value of the variable on the left side of the equal sign by the value that is specified on the right side of the equal sign.

  • /=   Divide the current value of the variable on the left side of the equal sign by the value that is specified on the right side of the equal sign.

  • %=   Modify the current value of the variable on the left side of the equal sign by the value that is specified on the right side of the equal sign.

:

A colon can be used to separate a parameter's name and the parameter's value, as in the following example: -Enabled:$True. The use of a colon is optional with all parameter types except switch parameters. For more information about switch parameters, see Parameters.

!

The exclamation point is a logical NOT operator. When it is used with the equal ( ) sign, the combined pair means "not equal to."

[ ]

Brackets are used to specify the index value of an array position. For example, $Red[9] refers to the tenth index position in the array, $Red. It refers to the tenth index position because array indexes start at zero ( 0 ).

Brackets can also be used to assign a type to a variable, as in the following example: $A=[XML] "<Test><A>value</A></Test>". The following types are valid: Array, Bool, Byte, Char, Char[], Decimal, Double, Float, Int, Int[], Long, Long[], RegEx, Single, ScriptBlock, String, Type, and XML.

{ }

Braces are used to include an expression in a command, as in the following example: Get-Process | Where { $_.HandleCount -gt 400 }

|

The pipe symbol is used when one cmdlet pipes a result to another cmdlet. For example, the following command pipes the results from the Get-Mailbox cmdlet to the Set-Mailbox cmdlet: Get-Mailbox -Server SRV1 | Set-Mailbox -ProhibitSendQuota 2GB

>

The right-angle bracket is used to send the output of a command to a file, as in the following example: Get-TransportRulePredicate > c:\out.txt. The destination file is overwritten.

>>

Double right-angle brackets are used to append the output of a command to a file, if the file exists. If the file doesn't exist, a new file is created. The following is an example of how to use double right-angle brackets: Get-TransportRulePredicate >>c:\out.txt

" "

Quotation marks are used to enclose a string that contains spaces.

$

A dollar sign indicates a variable. For example, $Blue = 10 assigns the value 10 to the variable $Blue.

@

The @ symbol references an associative array. For more information, see Arrays.

$( )

A dollar sign ( $ ) with parentheses indicates command substitution. You can use command substitution when you want to use the output of one command as an argument in another command, as in the following example: Get-ChildItem $(Read-Host -Prompt "Enter FileName: ")

..

Double-periods indicate a value range. For example, if an array contains several indexes, you can specify the following command to return the values of all indexes between the second and fifth indexes, as in the following example: $Blue[2..5]

+

The + operator adds two values together. For example, 6 + 6 equals 12.

-

The - operator subtracts one value from another value. For example, 12 - 6 equals 6.

The - operator can also be used to represent a negative number, such as -6. For example, -6 * 6 equals -36.

*

A wildcard character has several meanings. You can use wildcard characters to match strings, to multiply numeric values, or, if strings and numeric values are used together, to repeat the string value the number of times that is specified by the numeric value, as in the following example: "Test" * 3 equals TestTestTest.

/

The / operator divides one value by another. For example, 6 / 6 equals 1.

%

When used in a numerical evaluation, the % operator returns the remainder from a division operator. For example, 6 % 4 equals 2.

When used in a pipeline, the percent character ( % ) is shorthand for the ForEach cmdlet. For example, instead of the command Import-Csv c:\MyFile.csv | ForEach { Set-Mailbox $_.Identity -Name $_.Name }, you can use Import-Csv c:\MyFile.csv | % { Set-Mailbox $_.Identity -Name $_.Name }.

For more information, see Pipelining.

?

The question mark character ( ? ) is shorthand for the Where cmdlet. For example, instead of Get-Alias | Where {$_.Definition -eq "Clear-Host"}, you can use Get-Alias | ? {$_.Definition -eq "Clear-Host"}.