Export-CSV Powershell

05 May,2012 by Jack Vamvas

Question: How can I export a Powershell recordset to a CSV file format, so I can then open the file in MS Excel?

Answer:   Powershell has the Export-CSV cmdlet . The Export-CSV cmdlet creates a CSV  file  of the script output.  The script needs to pipe the results to the Export-CSV cmdlet – with a filename parameter.

I add –notype to the Export-CSV cmdlet , as I prefer to not include the .Net object type in the first line

Get-Process | Where-Object {$_.PrivateMemorySize -gt 100MB} | SELECT ProcessName, PrivateMemorySize | Export-CSV -notype c:\privatememory.csv 

 

See Also

SQL Server – Powershell Excel to HTML


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Export-CSV Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer