Powershell output to Desktop

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
  • How to save command output to file using 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:

  • Windows 10 on Windows Central All you need to know
  • Windows 10 help, tips, and tricks
  • Windows 10 forums on Windows Central
Buyer's guide

Do the XPS 13 2-in-1's features beat out the Inspiron 13 2-in-1's price?

We compare Dell's XPS 13 2-in-1 [9310] with the more affordable Inspiron 13 2-in-1 [7306]. There's a clear winner in terms of features and design, but the price will no doubt play a big factor.

Buyer's guide

Which XPS 15 display is best for you?

While the laptops look the same and have mostly the same features, there are some key differences to know about when choosing between the FHD+, 3.5K OLED, and UHD+ XPS 15 9510 models.

Survive the truth

Here's everything we know about Destiny 2: The Witch Queen

Destiny 2: The Witch Queen is coming early in 2022, and it sounds like it might end up being one of the game's biggest and most revolutionary expansions ever. Here's an overview of everything we know about The Witch Queen so far.

Make it your own

These apps help you customize the look of Windows 11

Windows 11 has a new look, including a new Start menu and redesigned Taskbar. If you don't like the look of Windows 11, you can customize it with these apps.

Video liên quan

Chủ Đề