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
Update 6: Microsoft wants all of TikTok, but Trump's order may interfere
The Financial Times reports that as part of negotiations, Microsoft is now inquiring whether it can buy all of TikTok, instead of just the business in the US., Canada, Australia, and New Zealand. This new plan would include India and Europe (and excluding China).
Apple responds to Project xCloud iOS block, Microsoft kicks back
With Microsoft's Project xCloud streaming platform locked out from iOS devices, Apple doubles down on App Store restrictions.
Microsoft-TikTok deal is a 'poison chalice,' says Bill Gates
In a new interview, former Microsoft CEO Bill Gates called a potential deal to acquire TikTok a "poison chalice," referencing the fraight nature of TikTok's forced sale in the U.S.
10 must-have apps for any new PC
You just purchased a new PC and set it up, and now you're looking for some great apps. Look no further. These are the best apps for your new Windows 10 PC.