If you want to export a command output to a file, in this guide, we'll show you how on PowerShell and Command Prompt.
On Windows 11 and Windows 10, the ability to save the Command Prompt or PowerShell command output to a text file can be helpful many situations. For instance, it's a convenient way to export the command output for analysis to troubleshoot a problem. You can also print the return of a command to a text file to save a configuration for documentation purposes and more.
You can always select and right-click the content to copy the output to the clipboard and paste it to text files. However, the approach requires additional steps, which you can avoid with a single command using the redirected output to the file function.
In this Windows 11 guide, we will walk you through the steps to save the command output to a text file on Command Prompt or PowerShell.
How to save command output to file using Command Prompt
To save the command output to a text file with Command Prompt, use these steps:
- Open Start.
- Search for Command Prompt.
- Right-click the top result and select the Run as administrator option.
Type the following command to save the output to a text file and press Enter:
YOUR-COMMAND > C:\PATH\TO\FOLDER\OUTPUT.txt
In the command, replace "YOUR-COMMAND" with your command and "c:\PATH\TO\FOLDER\OUTPUT.txt" with the path and file name to store the output. This example exports the system technical specifications to the "laptop_tech_specs.txt" file:
systeminfo > C:\laptop_tech_specs.txt
(Optional) Type the following command to save the output and view results on the screen and press Enter:
YOUR-COMMAND > C:\PATH\TO\FOLDER\OUTPUT.txt | type C:\PATH\TO\FOLDER\OUTPUT.txt
In the command, replace "YOUR-COMMAND" with your command and "c:\PATH\TO\FOLDER\OUTPUT.txt" with the path and filename to store and view the output. This example exports the system technical specifications to the "laptop_tech_specs.txt" file and prints the information on the screen:
systeminfo > C:\laptop_tech_specs.txt | type C:\laptop_tech_specs.txt
Quick tip: If you have problems viewing the file, you can use the
type c:\PATH\TO\FOLDER\OUTPUT.txt
command after step 3.
Once you complete the steps, the command output will be saved into a text file, which you can then review or share with tech support.
How to save command output to file using PowerShell
To save the command output to a text file with PowerShell on Windows 11 or Windows 10, use these steps:
- Open Start.
- Search for PowerShell.
- Right-click the top result and select the Run as administrator option.
Type the following command to save the output to a text file and press Enter:
YOUR-COMMAND | Out-File -FilePath C:\PATH\TO\FOLDER\OUTPUT.txt
In the command, replace "YOUR-COMMAND" with your command and "c:\PATH\TO\FOLDER\OUTPUT.txt" with the path and file name to store the output. This example exports the IP address configuration to the "laptop_network_settings.txt" file:
ipconfig | Out-File -FilePath C:\laptop_network_settings.txt
(Optional) Type the following command to view the saved output on the screen and press Enter:
Get-Content -Path C:\PATH\TO\FOLDER\OUTPUT.txt
In the command, replace "c:\PATH\TO\FOLDER\OUTPUT.txt" with the path and file name with the output content. This example shows the contents of the "laptop_network_settings.txt" file:
Get-Content -Path C:\laptop_network_settings.txt
After you complete the steps, PowerShell will save the result into a text file on your specified location.
More Windows resources
For more helpful articles, coverage, and answers to common questions about Windows 10 and Windows 11, visit the following resources: