Exporting to CSV and XML
In this recipe, we pipe the results of the Get-Process
cmdlet to a CSV and XML file.
How to do it...
These are the steps required to export to CSV and XML:
- Open PowerShell ISE as an administrator.
- Add the following script and run it:
$csvFile = "C:\Temp\sample.csv" Get-Process | Export-Csv -path $csvFile -Force -NoTypeInformation #display text file in notepad notepad $csvFile $xmlFile = "C:\Temp\process.xml" Get-Process | Export-Clixml -path $xmlFile -Force #display text file in notepad notepad $xmlFile
How it works...
PowerShell provides a few cmdlets that support exporting data to files of different formats. The Export-Csv
cmdlet saves information to a comma-separated value file, and the Export-Clixml
cmdlet exports the piped ...
Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.