On Windows 10, the ability to save the output of a PowerShell or Command Prompt command to a text file can come in handy in many scenarios. For example, when you’re troubleshooting a problem, it’s a convenient way to export and analyze the command output, or you can share the output with someone else who can help. You can print a command output to a text file to save system configurations for documentation purposes, and more.

Although you could just select the content, right-click the selection to copy the content to the clipboard, and then paste on a text file, this method requires additional steps, which you can avoid with a single command-line using the redirect output to file function.

In this Windows 10 guide, we’ll walk you through the steps to save a command output to a text file whether you’re using Command Prompt or PowerShell.

How to save command output to file using Command Prompt

To save a command output to a text file using Command Prompt, use these steps:

  1. Open Start.
  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  3. 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 make sure to replace “YOUR-COMMAND” with your command-line and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name to store the output.

  4. (Optional) If you want to save the output, and view the result on the screen, then use this command and press Enter:

    YOUR-COMMAND > c:\PATH\TO\FOLDER\OUTPUT.txt | type c:\PATH\TO\FOLDER\OUTPUT.txt

    In the command make sure to replace “YOUR-COMMAND” with your command-line and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and filename to store and view the output.

    Quick tip: If you’re having issues viewing the file, you can use the type c:\PATH\TO\FOLDER\OUTPUT.txt command after step No. 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 a command output to a text file using PowerShell, use these steps:

  1. Open Start.
  2. Search for PowerShell, right-click the top result, and select the Run as administrator option.
  3. 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 make sure to replace “YOUR-COMMAND” with the command-line that you want and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name to store the output.

  4. (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 make sure to replace “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name with the output content.

After completing the steps, the PowerShell command will save the result into a text file on the location that you specified.

We’re focusing this guide on Windows 10, but you can also use these instructions on Windows 8.1 and Windows 7.

More Windows 10 resources

For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

Let a comment