-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
PowerShell 7 Workshop
By :
If we want our PowerShell objects in a format other than text, we’re going to need to process them somehow. There are two groups of cmdlets that let us do that. The ConvertTo- cmdlets convert the objects in our pipeline into data of a particular type, such as CSV or HTML data. The Export- cmdlets combine the equivalent ConvertTo- cmdlet with an Out-File function to produce a file of the relevant type. In this chapter, we’re going to cover three common file types; CSV, XML, and HTML.
Let’s look at the ConvertTo-CSV cmdlet first. With this cmdlet, we can take the output of another cmdlet and turn it into a CSV datastream. Try this:
Get-Process | ConvertTo-Csv
You’ll see something like the following screenshot:
Figure 6.4 – Nasty
Ugh. Horrible, right? However, we can then pipe that into Out-File as follows:
Get-Process w* | ConvertTo-Csv | Out-File C:\temp\poshbook\ProcessesConvertTo...
Change the font size
Change margin width
Change background colour