Main menu

Pages

How to save command output to a file using Command Prompt or PowerShell

In Windows 11 and Windows 10, the ability to save the output of a Command Prompt or PowerShell command to a text file can be useful in many situations. For example, it is a convenient way to export command output for analysis to troubleshoot the problem. You can also print the command back to a text file to save the configuration for documentation purposes and more.

You can always select the content and right-click it to copy the output to the clipboard and paste it into text files. However, the method requires additional steps, which you can avoid with a single command using the output redirected to the file function.

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

How to save command output to a file using Command Prompt

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

  1. Opens Started.
  2. searching for Command Prompt.
  3. Right click on the top result and select File Run as administrator to choose.
  4. Type the following command to save the output to a text file and hit Enters:

    YOUR-COMMAND > C:\PATH\TO\FOLDER\OUTPUT.txt

    In command, replace “your command” By your order 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

    Command Prompt, save the command output to a fileSource: Windows Central

  5. (Optional) Type the following command to save the output and display the results on the screen and press Enters:

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

    In command, replace “your command” By your order and “c:\PATH\TO\FOLDER\OUTPUT.txt” With the path and file name to store and display the output. This example exports the system’s 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

    Export command prompt and show outputSource: Windows Central

    Quick info: If you are having problems viewing the file, you can use the . extension type c:\PATH\TO\FOLDER\OUTPUT.txt It’s after Step 3.

Once you complete the steps, the command output will be saved to a text file, which you can then review or share with tech support.

How to save command output to a file using PowerShell

To save the command output to a text file using PowerShell on Windows 11 or Windows 10, use the following steps:

  1. Opens Started.
  2. searching for Powershell.
  3. Right click on the top result and select File Run as administrator to choose.
  4. Type the following command to save the output to a text file and hit Enters:

    YOUR-COMMAND | Out-File -FilePath C:\PATH\TO\FOLDER\OUTPUT.txt

    In command, replace “your command” By your order 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

    PowerShell save the output to a text fileSource: Windows Central

  5. (Optional) Type the following command to display the saved output on the screen and press Enters:

    Get-Content -Path C:\PATH\TO\FOLDER\OUTPUT.txt

    In command, replace “c:\PATH\TO\FOLDER\OUTPUT.txt” With the path and file name with the content of the output. This example shows the contents of the “laptop_network_settings.txt” file:

    Get-Content -Path C:\laptop_network_settings.txt

    PowerShell print text fileSource: Windows Central

After completing the steps, PowerShell will save the result to a text file in your specified location.

More Windows Resources

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

reactions

Comments