Changes

Jump to: navigation, search
no edit summary
A key requirements requirement of any command line shell or scripting language involves gaining an understanding of using quotation marks to encapsulate strings and escape sequences to enter special characters such as newlines or carriage returns. As Windows PowerShell is no exception to this rule, the objective of this chapter is provide a detailed overview of the different techniques for quoting and escaping strings and characters.
== Using Double Quotes ==
</pre>
Both these problems may be alleviated either by using single quotes or by escaping, both of which are covered in the following sections.
== Using Single Quotes ==
</pre>
In fact, anything placed inside single quotes is taken literally, with the expection of other single quotes which cause a problem similar to the use of doublke double quotes in a double quoted string. For example:
<pre>
== Using the PowerShell Escape Character ==
The PowerShell escape character takes the form of a back quote (`) and instructs PowerShell to treat the following character literally, as opposed to interpreting it in some other way. Those familiar with other shells and programming languages will be more familiar with using the back slash character (\) for escaping. The reason for the use of the back quote instead of the backslash is the direct result of the decision in the first version of DOS to use the backslash character to separate the different parts of a file path, for example ''C:\Windows\Program Files''. Other than this difference, but the concept of escaping is otherwise the same.
To understand the escape character, consider the first example in this chapter, whereby PowerShell interpreted the second word after the ''-inputobject'' paramater as an additional argument:
</pre>
The trick to including a back quote in a string and not have it treated as an escape character is to escape the back quote itself, in other words typing it was as ``:
<pre>
== PowerShell Special Escape Sequences ==
Escape sequences are involve the use of the back quote escape together with one other character to represent a special character that cannot otherwise be represented in a string. For example, a tab or new line. The following table lists the special escape sequences supported by Windows PowerShell:
<google>ADSDAQBOX_FLOW</google>
<table border="1" cellpadding="5" cellspacing="0" id="E3B" style="border-collapse: collapse; border-color:#cccccc; border-style: solid; border-width: 1px; margin-bottom:20px">
This is line 2
</pre>
 
<google>BUY_WPS_BOTTOM</google>

Navigation menu