Learning PowerCLI
上QQ阅读APP看书,第一时间看更新

Using here-strings

Until now, you have only seen single-line strings in this book. PowerShell has a so-called here-string that spans multiple lines. You use @" or @' to start the here-string and "@ or '@ to finish the here-string. The @"or @' must be at the end of a line and the "@ or '@ must be at the beginning of the line that terminates the here-string. As in single-line strings, variables and subexpressions are expanded in double-quoted here-strings and are not expanded in single-quoted here-strings.

The following command creates a here-string that spans two lines and puts the here-string in the variable $s:

PowerCLI C:\> $s = @"
>> Learning PowerCLI
>> is a lot of fun!
>> "@
>> $s
>>
Learning PowerCLI
is a lot of fun!