File Formatting

Convert Format

ConvertTo-Csv

Converts to CSV

ConvertTo-Html

Converts to HTML. This will reveal all properties.

ConvertTo-Json

Converts to JSON and reveals **nested properties

ConvertTo-Xml

Converts to XML

Example on Converting files To and from:

Get-Process | ConvertTo-Json | Out-File procs.json
Get-Content ./procs.json | ConvertFrom-Json

Import/Export

Get-Process | Export-Csv procs.csv

Exporting output to CSV

Export-Csv <filename.csv> -NoClobber

Does not overwrite the file

Export-CSV <filename.csv> -UseCulture

Uses the system’s default separator rather than a comma.

Import-Clixml

Imports XML file to be read in PS

Import-Csv

Imports CSV file to be read in PS

Import-Csv C:\path\to\file.csv | Format-Table -AutoSize

Formats a CSV file as a table with column width adjusted automatically.

Last updated

Was this helpful?