On Windows 10, if you work with PowerShell commands and scripts regularly, you probably want to keep a record of those commands and the output you see on the screen to a text file for troubleshooting or documentation purposes.
While you can always copy the information you need manually, or use different commands to export outputs individually, PowerShell also includes a much simpler command that allows you to create a transcript of an entire console session. Also, the transcript command has different options to control various aspects of the output file.
In this Windows 10 guide, we'll walk you through the steps to create a transcript of a PowerShell command session into a text file.
How to record a command session in PowerShell
To create a transcript of every command that you type in PowerShell in a particular console session, use these steps:
- Open Start.
- Search for PowerShell, click the top result to open the experience.
- Type the following command to start recording the session to a text file and press Enter:
Start-Transcript -Path "C:\FOLDER\PATH\POWERSHELL_TRANSCRIPT_FILENAME.txt" -NoClobberIn the command, make sure to update the text output file with the location and filename that you want to use. The
-NoClobberswitch will prevent overwriting an existing recording.
Once you complete the steps, you can continue running commands normally, and in the background, PowerShell will create a transcript in a text file, and it'll save it in the path that you specified in the command.
After you finish using PowerShell, you can close the console or use the
command to terminate the recording. Then you can open the text file with any text editor to see all the commands you typed as well as their output as they appeared in the console.
In addition, you'll notice that the command also saves other relevant information, such as start time of the transcript, whether the console was using elevated privileges, computer name, version of Windows 10, and more.
The Start-Transcript command also includes a number of other switches to control the behavior. For instance, if you use the
switch in the command instead of the
, then the new session will be saved at the end of the existing output file.
Start-Transcript -Path "C:\sessions\ps_recording01.txt" -Append
You can also use the
switch at the end of the command to log the exact time when each command in the session was executed.
Start-Transcript -Path "C:\sessions\ps_recording01.txt" -NoClobber -IncludeInvocationHeader
If you don't want to deal with filenames, then you can use the
switch, instead of the
switch, in the command to allow PowerShell to name the output files automatically.
Start-Transcript -OutputDirectory "C:\sessions"
Other available switches include:
- -Confirm: Instructs PowerShell to ask for confirmation before starting the recording session.
- -Force: Allows you save the commands you type and output to a read-only file.
- -LiteralPath: Lets you specify a path literally without identifying any of the characters as wildcards.
- -WhatIf: Allows to test the command before starting a transcript.
We're focusing this guide on Windows 10, but you can also use these instructions in older versions of the OS, and other supported platforms, including macOS and Linux.
More Windows 10 resources
For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:
- Windows 10 on Windows Central – All you need to know
- Windows 10 help, tips, and tricks
- Windows 10 forums on Windows Central
Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he's a recognized member of the Microsoft MVP community.
Nice writeup Mauro. I always forget about this little gem of a command.
This is cool, but I'm not sure I see an advantage over using Powershell ISE. Am I missing something?
Thanks Mauro, that's a nice tip
Thank you for signing up to Windows Central. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.