Save PowerShell Output to a Log File

PowerShell can display output and save a log at once: pipe the command to Tee-Object. For a whole troubleshooting session, run Start-Transcript before your commands and Stop-Transcript afterward.

Use file redirection when you only want the saved result. The choice depends on the record you need: one command's results, any errors, or the commands and screen output from a longer session.

Keep one command visible while saving its output

Open Windows PowerShell or PowerShell 7. Pick a folder you can write the log to first. The examples use your profile folder, so they work regardless of your Windows username or where your Documents folder is stored.

Run this read-only example to list processes and save the same output:

Get-Process | Tee-Object -FilePath "$HOME\processes.txt"

The process list should still appear in the terminal, and processes.txt should be created in your profile folder. Open that file in a text editor to check the saved text.

Drawing of a PowerShell command using Tee-Object to save a process list while keeping terminal output

Microsoft's Tee-Object instructions describe both destinations: the file and the pipeline. When Tee-Object is last in this pipeline, the output also appears in the console.

Replace Get-Process with the command whose output you need. Keep the pipe character and the Tee-Object part. If the command takes parameters, put them before the pipe.

By default, this writes a new result to the named file and replaces anything already in the file. Use a new filename when each run should have its own record.

For repeated entries in the same file, add -Append:

Get-Date | Tee-Object -FilePath "$HOME\session.log" -Append

That simple example adds the current date and time without changing system settings. In a real troubleshooting session, timestamps help distinguish one attempt from the next.

Capture errors as well as ordinary output

PowerShell separates ordinary results from errors, warnings, and other kinds of messages. These are called streams. A plain pipe to Tee-Object captures ordinary results, so an error you see on screen can be missing from the file.

To combine PowerShell's redirectable streams before saving them, put *>&1 immediately before the pipe:

Get-Item -LiteralPath "$HOME\missing-example.txt" *>&1 | Tee-Object -FilePath "$HOME\command.log"

If that example file doesn't exist, you'll see an error, and the combined output goes through Tee-Object. It doesn't create the missing file.

The redirection reference lists the available streams. The progress display can't be redirected, so this syntax won't save a moving progress indicator as log text.

Use 2>&1 instead when you specifically want to merge errors into normal output without merging every other redirectable stream. The placement matters: merge the streams before sending the result to the log.

If the file is empty, check whether the command actually printed results or only showed progress. Also check whether the command's own options stopped it from printing messages.

Record a whole session with a transcript

For a support case involving several commands, start a transcript before running them:

Start-Transcript -Path "$HOME\support-session.txt" -NoClobber

The startup message gives the transcript location. Run the commands needed for the issue, then finish the record:

Stop-Transcript

Review support-session.txt for the commands and results you meant to record. -NoClobber prevents overwriting an existing file, so choose a new name if PowerShell reports that the file already exists.

I'd use a transcript when someone needs to see both the commands you entered and what happened afterward. Tee-Object is cleaner when the only useful material is one command's result.

A transcript can include account names, file paths, and sensitive values printed or typed during the session. Read it before sharing, and remove private information from the copy you send.

Start the transcript in the same PowerShell session that will run the commands. It won't collect output from before you started it or record every separate terminal window on your PC.

Save output quietly with redirection

When you don't need the result displayed as well, use > to send normal output to a file:

Get-Process > "$HOME\processes.txt"

Use >> to append instead of replacing the file's contents. To save all redirectable PowerShell streams in one file, use *>:

Get-Process *> "$HOME\processes-all.txt"

A quiet terminal is expected with this form. Check the destination file before assuming the command failed. A file extension such as .log or .txt changes the name, not what the command records.

To choose UTF-8 directly, use Out-File -Encoding utf8:

Get-Process | Out-File -FilePath "$HOME\processes.txt" -Encoding utf8

Windows PowerShell 5.1 and PowerShell 7 use different default encodings, which control how a file stores characters. Choose UTF-8 for use in another program; the older shell can add a starting marker called a UTF-8 byte-order mark.

Choose structured export when a table is the goal

A text log is meant to be read. If you need columns for a spreadsheet or another script, export the original records before formatting them for display:

Get-Process | Select-Object ProcessName, Id, CPU | Export-Csv -Path "$HOME\processes.csv" -NoTypeInformation

That makes a CSV with the selected properties. Don't put Format-Table before Export-Csv; it exports instructions for displaying a table rather than the process records you wanted.

If your source is a script file, first check that it runs through the Windows script procedure. Logging won't fix a wrong shell, missing dependency, or an execution-policy error.

When a file can't be written, check the folder's location and your permission to write there before opening PowerShell as an administrator. Your own profile folder is a better first destination than a protected Windows folder.

Keep the first error and the PowerShell version for the script maintainer. For older inventory instructions, the WMIC replacement commands give the PowerShell equivalents whose output you can save.

The Short Version

Use Tee-Object for output plus a file, Start-Transcript for a session, or redirection for a file alone. Merge errors when needed and append to keep earlier entries. Check the log before sharing it with support.

Checked December 2, 2026.

If you have any business, I can build it online

Hi, I’m Hamza. I’ve been building websites and online shops for business owners since 2019, and I also built this site you’re reading.

Tell me what business you have or what you’re working on. I’ll look into how much it can grow online, and then we talk. You don’t have to buy anything or hire me first.

Chat with me on my site and I’ll show you proof of businesses I’ve helped and how they’ve grown.

Written by Isaac Smith

Isaac Smith is the founder and editor of PC Glance, a website that covers computers, laptops, and technology. He is a tech enthusiast and a computer geek who loves to share his insights and help his readers make smart choices when buying tech gadgets or laptops. He is always curious and updated about the latest tech trends.

More from Isaac Smith

Leave a Comment