Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use Here-Strings with PowerShell

$
0
0

Summary: Learn the basic use of a here-string in Windows PowerShell.

Hey, Scripting Guy! Question What is a here-string and how do I use it?

Hey, Scripting Guy! AnswerIn PowerShell, you can use here-strings to declare blocks of text. They’re declared just like regular strings except they have an @ on each end. Instead of being limited to one line, you can declare an entire block or a multiple line string. Here-strings are also useful for making a string composed of the text to execute a command. Try these examples:

$String1 = @" 
Get-ChildItem c:\temp 
"@

$String2 = @" 
This is some
multiple line 
text! 
"@


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>