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:
The following output is displayed:
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:
The following output is displayed:
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 the "User-Defined Variables" and "Shell Variables" sections later in this white paper.
You may also need to display some characters, such as the dollar sign ($), double or single quotation marks, or back quotation mark (`). These characters have special meanings when used 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 enclosed with double quotation marks, you must use the back quotation mark escape character (`). For example, type the following on the command line:
The following output is displayed:
Because we used the 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 within a string. If you want to display a single quotation mark within 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!