Export Console - PowerShell


The Export-Console command in PowerShell exports the current console session, including the command history, output, and any errors, to an HTML or XML file. This can be useful for documenting your work, sharing it with others, or creating a reusable script.


Export-Console [-Path] <String> [-Force] [-IncludeHidden] [-IncludeTimestamps] [-OutputFileFormat] <String> [-NoWrap]


| Option | Description |
| -Path | The path to the output file. |
| -Force | Overwrite the output file if it already exists. |
| -IncludeHidden | Include hidden commands in the output. |
| -IncludeTimestamps | Include timestamps in the output. |
| -OutputFileFormat | The format of the output file. Can be either “HTML” or “XML”. |
| -NoWrap | Do not wrap lines in the output file. |


Export the current console session to an HTML file:

Export-Console -Path "C:\path\to\output.html"

Export the current console session to an XML file:

Export-Console -Path "C:\path\to\output.xml" -OutputFileFormat "XML"

Export the current console session and include hidden commands:

Export-Console -Path "C:\path\to\output.html" -IncludeHidden

Common Issues

The output file is empty.

Make sure that the -Path parameter is set to a valid path and that you have sufficient permissions to write to the specified location.

The output file contains errors.

The Export-Console command may encounter errors while exporting the console session. These errors will be included in the output file.


The Export-Console command can be used with other PowerShell commands or tools to create powerful scripts. For example, you could use the Export-Console command to create a reusable script that documents a complex task.

  • Get-Command
  • Get-History
  • Write-Output