You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/exchange-server/exchange-cmdlet-syntax.md
+31-33Lines changed: 31 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Exchange cmdlet syntax"
3
3
ms.author: chrisda
4
4
author: chrisda
5
5
manager: serdars
6
-
ms.date: 11/30/2015
6
+
ms.date:
7
7
ms.audience: Admin
8
8
ms.topic: article
9
9
ms.service: exchange-online
@@ -28,25 +28,25 @@ Exchange PowerShell help follows conventions that indicate what's required or op
28
28
29
29
|**Symbol**|**Description**|
30
30
|:-----|:-----|
31
-
|-|A hyphen indicates a parameter. For example, `-Identity`.|
32
-
|\<\>|Angle brackets indicate the possible values for a parameter. For example, `-Location <ServerName>` or `-Enabled <$true | $false>`.|
33
-
|[]|Square brackets indicate optional parameters and their values. For example, `[-WhatIf <SwitchParameter>]`. Parameter-value pairs that aren't enclosed in square brackets are required.|
34
-
|\||Pipe symbols in parameter values indicate a choice between values. For example, -Enabled \<$true \| $false\> indicates the _Enabled_ parameter can have the value `$true` or `$false`.|
31
+
| - |A hyphen indicates a parameter. For example, `-Identity`.|
32
+
|\<\>|Angle brackets indicate the possible values for a parameter. For example, `-Location <ServerName>` or -Enabled \<$true \| $false\>.|
33
+
|[ ]|Square brackets indicate optional parameters and their values. For example, `[-WhatIf]` or ` [-ResultSize <Unlimited>]`. <br/> Parameter-value pairs that aren't enclosed in square brackets are required. For example, `-Password <SecureString>`. <br/> If the parameter name itself is enclosed in square brackets, that indicates the parameter is a _positional_ parameter (you can use the parameter value without specifying the parameter), and positional parameters can be required or optional. <br/> For example, `Get-Mailbox [[-Identity] <MailboxIdParameter>]` means the _Identity_ parameter is positional (because it's enclosed in square brackets) and optional (because the whole parameter-value pair is enclosed in square brackets), so you can use `Get-Mailbox -Identity <MailboxIdParameter>` or `Get-Mailbox <MailboxIdParameter>`. Similarly, `Set-Mailbox [-Identity] <MailboxIdParameter>` means the _Identity_ parameter is positional (because it's enclosed in square brackets) and required (because the whole parameter-value pair is not enclosed in square brackets), so you can use `Set-Mailbox -Identity <MailboxIdParameter>` or `Set-Mailbox <MailboxIdParameter>`.|
34
+
|\||Pipe symbols in parameter values indicate a choice between values. For example, -Enabled \<$true \| $false\> indicates the _Enabled_ parameter can have the value `$true` or `$false`.|
35
35
36
36
These command conventions help you understand how a command is constructed. With the exception of the hyphen that indicates a parameter, you don't use these symbols as they're described in the table when you run cmdlets in Exchange PowerShell.
37
37
38
38
## Parameter sets in Exchange PowerShell
39
-
Parameter sets are groups of parameters that can be used with each other in the same command. Parameters that exist different parameter sets are mutually exclusive (they can't be used together in the same command).
39
+
Parameter sets are groups of parameters that can be used with each other in the same command. Although parameter sets typically share some parameters, each parameter set contains at least one parameter that isn't available in the other parameter sets, and can't be used with some of the parameters in different parameter sets.
40
40
41
41
Many cmdlets have only one parameter set, which means that all available parameters can be used with each other. Other cmdlets have several parameter sets, which indicates some parameters perform functions that are incompatible with other parameters. For example, suppose the following parameter sets are available on the **New-SystemMessage** cmdlet:
This cmdlet has two separate parameter sets. This indicates that you can use these parameters together in the same command:
49
+
This cmdlet has two separate parameter sets. Based on the entries, you can use these parameters together in the same command:
50
50
51
51
-_DsnCode_
52
52
@@ -108,33 +108,31 @@ In any programming language, an escape character is used to identify special cha
108
108
109
109
For example, if you want the output `The price is $23`, enter the value **"The price is \`$23"**. The escape character is required because the dollar sign character ( $ ) defines variables in Exchange PowerShell.
110
110
111
-
If you enclose the string in single quotation marks, the only special character you need to worry about is the single quotation mark character itself, which requires two single quotation marks ( '' ).
111
+
If you enclose the string in single quotation marks, the only special character you need to worry about is the single quotation mark character itself, which requires two single quotation marks ( '' ).
112
112
113
113
For example, if you want the output `Don't confuse two single quotation marks with a double quotation mark!`, enter the value **'Don''t confuse two single quotation marks with a double quotation mark!'**.
114
114
115
115
## Command operators in Exchange PowerShell
116
-
The following table shows the valid operators that you can use in an Exchange command. Some of these symbols were also described in the earlier Command conventions in Exchange PowerShell section. However, these symbols have different meanings when they're used on the command line as operators. For example, the minus sign that's used to indicate a parameter can also be used in a command as a mathematical operator.
116
+
The following table shows the valid operators that you can use in an Exchange command. Some of these symbols were also described in the earlier [Command conventions in Exchange PowerShell](#command-conventions-in-exchange-powershell) section. However, these symbols have different meanings when they're used on the command line as operators. For example, the minus sign that's used to indicate a parameter can also be used in a command as a mathematical operator.
117
117
118
118
|**Operator**|**Description**|
119
119
|:-----|:-----|
120
-
|**=** | 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: <br/> • **+=**: Add the value on the right side of the equal sign to the current value that's contained in the variable on the left side of the equal sign. <br/> • **-=**: Subtract the value on the right side of the equal sign from the current value that's contained in the variable on the left side of the equal sign. <br/> • **\*=**: Multiply the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign. <br/> • **/=**: Divide the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign. <br/> • **%=**: Modify the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign. |
121
-
|**:**| A colon can be used to separate a parameter's name from the parameter's value. For example, `-Enabled:$True`. Using a colon is optional with all parameter types except switch parameters. For more information about switch parameters, see [Parameters](https://technet.microsoft.com/library/bc81f639-c822-4b2b-a692-694c43f5f57e.aspx). |
122
-
|**!**| The exclamation point is a logical **NOT** operator. When it is used with the equal ( **=** ) sign, the combined pair means "not equal to." |
123
-
|**[]**| Brackets are used to specify the index value of an array position. Index values are offsets that start at zero. For example, `$Red[9]` refers to the tenth index position in the array, `$Red`. <br/> Brackets can also be used to assign a type to a variable (for example, `$A=[XML] "<Test><A>value</A></Test>"`). The following variable types are available: `Array`, `Bool`, `Byte`, `Char`, `Char[]`, `Decimal`, `Double`, `Float`, `Int`, `Int[]`, `Long`, `Long[]`, `RegEx`, `Single`, `ScriptBlock`, `String`, `Type`, and `XML.`|
124
-
|**{ }**|Braces are used to include an expression in a command. For example, Get-Process \| Where {$\_.HandleCount -gt 400} |
125
-
|**\|**|The pipe symbol is used when one cmdlet pipes a result to another cmdlet. For example, Get-Mailbox -Server SRV1 \| Set-Mailbox -ProhibitSendQuota 2GB. |
126
-
|**\>**|The right-angle bracket is used to send the output of a command to a file, and the contents of the file are overwritten. For example, `Get-TransportRulePredicate > "C:\My Documents\Output.txt"`. |
127
-
|**\>\>**|Double right-angle brackets are used to append the output of a command to an existing file. If the file doesn't exist, a new file is created. For example, `Get-TransportRulePredicate >> "C:\My Documents\Output.txt"`. |
128
-
|**"**|Double quotation marks are used to enclose text strings that contains spaces. |
129
-
|**$**|A dollar sign indicates a variable. For example, `$Blue = 10` assigns the value `10` to the variable `$Blue`. |
130
-
|**@**|The @ symbol references an associative array. For more information, see [Arrays](https://technet.microsoft.com/library/599ed6d7-553a-41be-b4a3-aa75ab9dbb5d.aspx). |
131
-
|**$( )**|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. For example, `Get-ChildItem $(Read-Host -Prompt "Enter FileName: ")`. |
132
-
|**..**|Double-periods indicate a value range. For example, if an array contains several indexes, you can return the values of all indexes between the second and fifth indexes by running the command: `$Blue[2..5]`. |
133
-
|**+**|The **+** operator adds two values together. For example, `6 + 6` equals `12`. |
134
-
|**-**|The **-** operator subtracts one value from another value (for example, `12 - 6` equals `6`) or indicates a negative number (for example, `-6 * 6` equals `-36`). |
135
-
|**\***|You can use the wildcard character to match strings (for example, Get-User \| Where-Object {$\_.Department -like 'Sales*'}), multiply numeric values (for example, `6 * 6` equals `36`), or repeat the string value the specified number of times (for example, `"Test" * 3` equals `TestTestTest`).|
136
-
|**/**|The **/** operator divides one value by another. For example, `6 / 6` equals `1`. |
137
-
|**%**|In a numerical evaluation, the **%** operator returns the remainder from a division operator. For example, `6 % 4` equals `2`. <br/> In a pipeline, the percent character ( `%` ) is shorthand for the **ForEach-Object** cmdlet. For example, Import-Csv c:\MyFile.csv \| ForEach-Object {Set-Mailbox $\_.Identity -Name $\_.Name} is the same as Import-Csv c:\MyFile.csv \| % {Set-Mailbox $\_.Identity -Name $\_.Name}. For more information, see [Pipelining](https://technet.microsoft.com/library/59411ed3-926b-4eec-a462-84e6b26056c9.aspx). |
138
-
|**?**|The question mark character ( **?** ) is shorthand for the **Where-Object** cmdlet. For example, Get-Alias \| Where-Object {$\_.Definition -eq "Clear-Host"} is the same as Get-Alias \| ? {$\_.Definition -eq "Clear-Host"}|
139
-
140
-
120
+
|**=**|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: <br/> • **+=**: Add the value on the right side of the equal sign to the current value that's contained in the variable on the left side of the equal sign. <br/> • **-=**: Subtract the value on the right side of the equal sign from the current value that's contained in the variable on the left side of the equal sign. <br/> • **\*=**: Multiply the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign. <br/> • **/=**: Divide the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign. <br/> • **%=**: Modify the current value of the variable on the left side of the equal sign by the value that's specified on the right side of the equal sign.|
121
+
|**:**|A colon can be used to separate a parameter's name from the parameter's value. For example, `-Enabled:$True`. Using a colon is optional with all parameter types except switch parameters. For more information about switch parameters, see [Parameters](https://technet.microsoft.com/library/bc81f639-c822-4b2b-a692-694c43f5f57e.aspx).|
122
+
|**!**|The exclamation point is a logical **NOT** operator. When it is used with the equal ( **=** ) sign, the combined pair means "not equal to."|
123
+
|**[]**|Brackets are used to specify the index value of an array position. Index values are offsets that start at zero. For example, `$Red[9]` refers to the tenth index position in the array, `$Red`. <br/> Brackets can also be used to assign a type to a variable (for example, `$A=[XML] "<Test><A>value</A></Test>"`). The following variable types are available: `Array`, `Bool`, `Byte`, `Char`, `Char[]`, `Decimal`, `Double`, `Float`, `Int`, `Int[]`, `Long`, `Long[]`, `RegEx`, `Single`, `ScriptBlock`, `String`, `Type`, and `XML.`|
124
+
|**{ }**|Braces are used to include an expression in a command. For example, Get-Process \| Where {$\_.HandleCount -gt 400}|
125
+
|**\|**|The pipe symbol is used when one cmdlet pipes a result to another cmdlet. For example, Get-Mailbox -Server SRV1 \| Set-Mailbox -ProhibitSendQuota 2GB.|
126
+
|**\>**|The right-angle bracket is used to send the output of a command to a file, and the contents of the file are overwritten. For example, `Get-TransportRulePredicate > "C:\My Documents\Output.txt"`.|
127
+
|**\>\>**|Double right-angle brackets are used to append the output of a command to an existing file. If the file doesn't exist, a new file is created. For example, `Get-TransportRulePredicate >> "C:\My Documents\Output.txt"`.|
128
+
|**"**|Double quotation marks are used to enclose text strings that contains spaces.|
129
+
|**$**|A dollar sign indicates a variable. For example, `$Blue = 10` assigns the value `10` to the variable `$Blue`.|
130
+
|**@**|The @ symbol references an associative array. For more information, see [Arrays](https://technet.microsoft.com/library/599ed6d7-553a-41be-b4a3-aa75ab9dbb5d.aspx).|
131
+
|**$( )**|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. For example, `Get-ChildItem $(Read-Host -Prompt "Enter FileName: ")`.|
132
+
|**..**|Double-periods indicate a value range. For example, if an array contains several indexes, you can return the values of all indexes between the second and fifth indexes by running the command: `$Blue[2..5]`.|
133
+
|**+**|The **+** operator adds two values together. For example, `6 + 6` equals `12`.|
134
+
|**-**|The **-** operator subtracts one value from another value (for example, `12 - 6` equals `6`) or indicates a negative number (for example, `-6 * 6` equals `-36`).|
135
+
|**\***|You can use the wildcard character to match strings (for example, Get-User \| Where-Object {$\_.Department -like 'Sales*'}), multiply numeric values (for example, `6 * 6` equals `36`), or repeat the string value the specified number of times (for example, `"Test" * 3` equals `TestTestTest`).|
136
+
|**/**|The **/** operator divides one value by another. For example, `6 / 6` equals `1`.|
137
+
|**%**|In a numerical evaluation, the **%** operator returns the remainder from a division operator. For example, `6 % 4` equals `2`. <br/> In a pipeline, the percent character ( `%` ) is shorthand for the **ForEach-Object** cmdlet. For example, Import-Csv c:\MyFile.csv \| ForEach-Object {Set-Mailbox $\_.Identity -Name $\_.Name} is the same as Import-Csv c:\MyFile.csv \| % {Set-Mailbox $\_.Identity -Name $\_.Name}. For more information, see [Pipelining](https://technet.microsoft.com/library/59411ed3-926b-4eec-a462-84e6b26056c9.aspx).|
138
+
|**?**|The question mark character ( **?** ) is shorthand for the **Where-Object** cmdlet. For example, Get-Alias \| Where-Object {$\_.Definition -eq "Clear-Host"} is the same as Get-Alias \| ? {$\_.Definition -eq "Clear-Host"}|
0 commit comments