I have a foreach loop and use the write-host cmdlet to write to the console.
I now wish to write the lines into a variable that will store all of the result from the loop.
What is the cmdlet/syntax for this?
I have a foreach loop and use the write-host cmdlet to write to the
Share
Here are couple of ways to do this. Putting the lines in a single string:
Or as an array of strings where each line is a different element in the array: