PowerShell and Files – Reading, Writing, and Manipulating Data
So far, our PowerShell journey has been on the screen. Wouldn’t it be neat to be able to write the output of our cmdlets to a file somewhere so that we could save it for later or send it to other people? That’s what we’re going to do in this chapter. First, we’re going to look at formatting output for the screen so that we can just focus on the things we’re interested in or present output in a more useful manner. Next, we’re going to look at writing the output to a text file using Out-File
. I do this multiple times a day and it’s an incredibly useful technique, but it is very limited, so we’re also going to look at creating Comma-Separated Value (CSV) files for consumption by another program, such as Microsoft Excel, and HTML files so that we can display our output as a web page.
Once we’re comfortable with the output, we’re going to dive into...