Export (0) Print
Expand All

Syntax

 

Applies to: Exchange Server 2007 SP3, Exchange Server 2007 SP2, Exchange Server 2007 SP1, Exchange Server 2007

Topic Last Modified: 2007-02-08

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 Exchange Management Shell can process the command. In the Exchange Management Shell, parameter sets are displayed in the Usage section of a cmdlet help topic. In the Microsoft Exchange Server 2007 Help file, parameter sets are displayed in the Syntax section of the cmdlet help topic.

For more information about cmdlet help, see Getting Help.

The Exchange Management 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 Exchange Management Shell Help and Exchange 2007 Help file.

Table 1 lists these command conventions.

Table 1   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 about parameters, 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. You don't type these conventions when you enter the command on the command line.

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:

New-SystemMessage -DsnCode <EnhancedStatusCode> -Internal <$true | $false>
-Language <CultureInfo> -Text <String> [-DomainController <String>] [-Templ
ateInstance <MshObject>]

New-SystemMessage -Language <CultureInfo> -QuotaMessageType <WarningMailbox
UnlimitedSize | WarningPublicFolderUnlimitedSize | WarningMailbox | Warning
PublicFolder | ProhibitSendMailbox | ProhibitPostPublicFolder | ProhibitSen
dReceiveMailBox> -Text <String> [-DomainController <String>] [-TemplateInst
ance <MshObject>]

The New-SystemMessage cmdlet has two parameter sets. 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. The remaining parameters, Language, Text, DomainController, and TemplateInstance, are listed in both parameter sets. This means that they can be used with the DsnCode parameter and Internal parameter and 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 New-AddressList cmdlet:

New-AddressList -Name <String> [-Company <MultiValuedProperty>] [-Container
 <AddressListIdParameter>] [-Department <MultiValuedProperty>] [-DisplayNam
e <String>] [-DomainController <String>] [-IncludedRecipients <Nullable>] [
-StateOrProvince <MultiValuedProperty>] [-TemplateInstance <MshObject>]

New-AddressList -Name <String> [-Container <AddressListIdParameter>] [-Disp
layName <String>] [-DomainController <String>] [-RecipientFilter <String>]
[-TemplateInstance <MshObject>] 

In the New-AddressList cmdlet, the first parameter set lists parameters that let you create a new address list based on values supplied to the Company, Department, IncludedRecipients, and StateOrProvice parameters. However, you can also create a new address list by using a custom filter that is specified with the RecipientFilter parameter. When you create a new address list, a custom filter that was specified by using the RecipientFilter parameter overrides anything that was configured by using the parameters that exist in the first parameter set. Therefore, the RecipientFilter parameter is put in its own parameter set. Exchange 2007 doesn't let you specify both parameters on the same command line. As with the New-SystemMessage cmdlet, the remaining parameters that exist in both parameters sets in the New-AddressList cmdlet can be used in any combination.

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:

Set-ReceiveConnector -Name "Contoso Receive Connector"

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

In the Exchange Management Shell, double quotation marks and single quotation marks ( ' ) have different meanings. When you enclose a string in double quotation marks, the Exchange Management 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:

"$Server Example"

The following output is displayed:

ServerName Example

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

When you enclose a string in single quotation marks, the Exchange Management 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:

'$Server-Example'

The following output is displayed:

$Server-Example

The variable $Server has not been replaced with a value because the Exchange Management 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.

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 Exchange Management Shell. To instruct the Exchange Management 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:

"The price is `$23."

The following output is displayed:

The price is $23.

Because we used the back quotation escape character with the dollar sign ( ), the Exchange Management 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:

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

The following output is displayed:

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

Use the operators in Table 2 when you type commands in the Exchange Management Shell. Some of the operators may match some of the previously mentioned command conventions. But they don't have the same meaning when they are typed on the command line. Table 2 shows the valid operators that you can use in a command.

Table 2   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 Move-Mailbox cmdlet: Get-Mailbox -Server SRV1 | Move-Mailbox -TargetDatabase SRV2

>

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 does not 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.

%

The % operator returns the remainder from a division operator. For example, 6 % 4 equals 2.

 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft