From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Using Out-String and Out-Host

Using Out-String and Out-Host - PowerShell Tutorial

From the course: Complete Guide to PowerShell 7

Using Out-String and Out-Host

- [Instructor] Now when working with values in PowerShell, obviously when we try to output things, there are various capabilities available to us. So the first one is what's called out-string. So I've got my list of processes here. So I'm going to say get process. You can see what comes back is a list like that. I'm going to actually populate this into a variable and say out string. Now when I go to my output here, what I end up with is just the same kind of table as before and I can say, write output, and it'll just write the output out as a string object. So it will process the list and convert it into a single string object. Now that's not always useful, especially when you have a vast amount of data like this, because normally data you want to iterate. However, you can convert all of that to a singular object. So let's just clear this bottom section here. I also can use what's called out-host, which will just display the output directly to the console. So I'm going to say Get…

Contents