Creating Excel Reports

by May 13, 2014

PowerShell objects can easily be opened in Microsoft Excel. Simply export the objects to CSV, then open the CSV file with the associated program (which should be Excel if it is installed).

This creates a report of running processes and opens in Excel:

$Path = "$env:temp\$(Get-Random).csv"
$originalProperties = 'Name', 'Id', 'Company', 'Description', 'WindowTitle'

Get-Process | 
  Select-Object -Property $originalProperties |
  Export-Csv -Path $Path -Encoding UTF8 -NoTypeInformation -UseCulture

Invoke-Item -Path $Path  

Note how -UseCulture automatically picks the correct delimiter based on your regional settings.

Twitter This Tip! ReTweet this Tip!