Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export the PowerShell output to a text file in tab-delimited format

Tags:

powershell

csv

How do I save the PowerShell script output to a text file in tab-delimited format?

Example - How do I export the output of the below PowerShell script to text, tab-delimited format?

Get-MailboxStatistics -Database data01 |ft displayname,databasename,itemcount,totalitemsize 
like image 624
Praveen2sas Avatar asked Apr 29 '13 19:04

Praveen2sas


People also ask

How do I Export output from PowerShell to excel?

As of now, there is no built-in command like CSV (Export-CSV) to export output to the excel file but we can use the Out-File command to export data to excel or any other file format. Let's use Out-File to export the output of the Get-Processes command to an excel file.

How do I Export PowerShell script results to CSV?

To do this we can use the Export-CSV function in PowerShell. The Export-CSV function converts PowerShell objects into a CSV string and saves them into a CSV file. If you only need a CSV string, then you can also use the ConvertTo-CSV function in PowerShell.

How do I Export a PowerShell script?

There are a couple of ways to write the output of PowerShell to a file. The most common ways are to use the Out-File cmdlet or the redirection operator > . Other options are to use the Set-Content and Add-Content cmdlet.


1 Answers

Use the Export-CSV with a tab delimiter. Note, that you can't use the output of format-table as an input to export-CSV, use select-object instead:

Get-MailboxStatistics -Database data01 |   select displayname,databasename,itemcount,totalitemsize |   export-csv -delimiter "`t" -path theOutFile.txt -notype 
like image 61
zdan Avatar answered Sep 19 '22 19:09

zdan