Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

PowerShell strings


In PowerShell, either double quotes or single quotes can be used to express string literals. For instance, the following values are the same:

"HELLO WORLD"
'HELLO WORLD'

Using both kinds of quotes can be useful when quoting strings which themselves contain quotes, such as the following:

"I can't stop using PowerShell"
'He said, "I like using PowerShell" all day long'

If a single quote is needed in a single-quoted string, you can double the quote (for example, 'can't is a contraction'). The same technique allows the use of double-quotes in a double-quoted string. Strings written this way can be somewhat confusing to look at and it is easy to lose track of the number of quotes. A simpler method of including a double quote character in a string is to escape it with the backtick (`), also called a grave accent. The following string is an example: "the `" character is a double quote".

A peculiar kind of string in PowerShell is called a here-string. Here-strings allow strings to...