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" -NoClobber
In 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
Stop-Transcript 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
-Append switch in the command instead of the
-NoClobber, 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
-IncludeInvocationHeader 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
-OutputDirectory switch, instead of the
-Path 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
Microsoft reportedly replacing dozens of journalists with AI on MSN
Roughly 50 employees will no longer work for MSN to curate news after this month. Recent reports state that Microsoft plans to replace these roles with artificial intelligence.
Samsung's new 'Access' smartphone upgrade program comes with Microsoft 365
Samsung has introduced a new upgrade program called Access in the U.S. In addition to making it easier for you to upgrade to a new phone, the subscription service also offers Samsung Premium Care and a Microsoft 365 subscription.
Review: Acer's Predator XN253Q X is a gaming monitor with blistering speeds
Looking for a monitor that can keep up with high-end PC hardware? Want to gain any competitive edge possible? The Acer Predator XN253Q X might just be what you're looking for.
Best Windows 10 Wallpaper Apps and Websites in 2020
You stare at your desktop wallpaper all day, so why leave it boring or as the Windows 10 default wallpaper? These websites and apps will help you keep your desktop fresh and beautiful.