Export FormatData - PowerShell


Export-FormatData converts data from PowerShell objects into a specified output format, most commonly a file on disk. It provides a convenient way to export data for reporting, archiving, or further processing.


Export-FormatData [-Culture <CultureInfo>] -Delimiters <Dictionary<String,String>> [-Destination <String>] [-Encoding <String>] [-File <String>] [-Format <FormatType>] [-LineTerminator <String>] [-NoTypeInformation] [-SkipHeader] [-Stream <Object>]

Required Parameters

  • Destination: The output location for the exported data. Can be a file path or stream.


  • Culture: Specifies the culture to use for formatting numerical and date/time values.
  • Delimiters: A hashtable defining custom delimiters to use for the exported data.
  • Encoding: The encoding to use for the exported data.
  • File: The output file path for the exported data.
  • Format: Specifies the output format. Supported formats include: CSV, XML, JSON, HTML, Markdown, and PowerShellData.
  • LineTerminator: The line terminator to use for the exported data.
  • NoTypeInformation: Omits type information from the exported data.
  • SkipHeader: Skips exporting the header information.
  • Stream: An object representing a stream where data should be exported.


Export to CSV File

Export-FormatData -Destination ".\export.csv" -Format CSV -Delimiters @{","="|""; "`n"="`r`n"}

Export to XML File

Export-FormatData -Destination ".\export.xml" -Format XML

Export to PowerShellData File

Export-FormatData -Destination ".\export.psd1" -Format PowerShellData

Common Issues

Incorrect Delimiters

Using incorrect delimiters may lead to malformed data. Ensure that the specified delimiters are compatible with the target format and application.

Data Truncation

If the exported data exceeds the specified output length, it may be truncated. Consider adjusting the output format or using a different tool for large data exports.


Export-FormatData can be integrated into scripts or combined with other commands for advanced tasks.

Export to Database

Export-FormatData -Format CSV | Import-Csv -Delimiter "|" | Export-SqlDataTable -DatabaseName "MyDatabase" -TableName "MyTable"

Export to Excel

Export-FormatData -Format CSV | Import-Csv | Export-Excel -Path ".\export.xlsx"
  • Format-Custom: Formats data using custom formatting rules.
  • ConvertTo-Csv: Converts PowerShell objects to CSV format.
  • ConvertTo-Html: Converts PowerShell objects to HTML format.