---
title: "Redirect PowerShell Output to a File with Out-File: A Complete Guide"
description: "Discover how to redirect PowerShell output to a file using the Out-File cmdlet with tips on preventing overwriting with the Append parameter"
canonical: "https://adamtheautomator.com/out-file/"
---

# Redirect PowerShell Output to a File with Out-File: A Complete Guide

> Discover how to redirect PowerShell output to a file using the Out-File cmdlet with tips on preventing overwriting with the Append parameter

Source: https://adamtheautomator.com/out-file/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Redirect PowerShell Output to a File with Out-File: A Complete Guide](https://adamtheautomator.com/wp-content/uploads/2019/06/out-file-powershell-redirect-file-powershell-write-to-file.png)

# Redirect PowerShell Output to a File with Out-File: A Complete Guide

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)16 June 20192 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [How Does Out-File Work?](#h-how-does-out-file-work)
*   [Sending Output to a File](#basic-out-file-usage)
*   [Appending to a File](#appending-with-out-file)
*   [Changing Up Output](#changing-up-out-file-output)
*   [Conclusion](#h-conclusion)

If you’re in the market for a PowerShell cmdlet that can store the output in a text file, you’re in luck. You’re about to learn how to use the PowerShell `Out-File` cmdlet along with its popular `Out-File -Append` parameter too!

## How Does Out-File Work?

This PowerShell cmdlet is simple in nature; it’s sole purpose is to store output received and store it in a text file.

It was designed to replace the [standard output redirection](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection?view=powershell-5.1) operator (`>`). Even from the DOS days, we could redirect output to a file. This cmdlet is the PowerShell way to do it.

The [`Out-File`](https://adamtheautomator.com/out-file/ "Out-File") cmdlet is typically used at the end of the PowerShell pipeline. Its sole purpose is to send the raw output directly to a text file with no regard. There are minimal ways to tweak how that output is written.

## Sending Output to a File

Let’s say you have a script that returns a list of all of the Windows services on your computer. When you run `Get-Service`, you will receive all of the objects you might expect on the console.

But maybe you’d like to save that output to a text file. The `Out-File` cmdlet is a great way to do that. You can use `it` by piping just about anything to to it via the pipeline.

You can see below, the output of `Get-Service` was sent to the cmdlet which created a text file called _Services.txt_ that contains the exact display that you see on the console.

```powershell
PS> Get-Service | Out-File -FilePath C:\Services.txt
PS> Get-Content C:\Services.txt
Status   Name               DisplayName

Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Stopped  Appinfo            Application Information
Stopped  AppMgmt            Application Management
<SNIP>
```

## Appending to a File

By default, it overwrites anything in the text file provided via the `FilePath` parameter. However, you can override this behavior by using the `Append` parameter.

Perhaps you’re accumulating console output in a file and would like to append text to a file rather than overwriting. The `Append` parameter is your best friend.

By using the `Out-File -Append` parameter you can see below, notice that if you don’t use it the C:\\File.txt is overwritten. But, as soon as you tack on the `Append` parameter, it appends the output to the end.

```powershell
PS> 'foo' | Out-File -FilePath C:\File.txt
PS> Get-Content -Path C:\File.txt
foo
PS> 'foo' | Out-File -FilePath C:\File.txt
PS> Get-Content C:\File.txt
foo
PS> 'foo' | Out-File -FilePath C:\File.txt -Append
PS> Get-Content C:\File.txt
foo foo
```

## Changing Up Output

By default, this cmdlet will attempt to replicate what’s shown on the console but there are some ways to manipulate it. For example, the cmdlet has a `NoNewLine` parameter that merely removes all newline characters.

```powershell
PS> Get-Service | Out-File -FilePath C:\Services.txt -NoNewline
PS> Get-Content C:\Services.txt
Status   Name               DisplayName
------   ----               -----------
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application La
```

Or, you can cut off the text on each row at a particular character count as well with the `Width` parameter.

```powershell
PS> Get-Service | Out-File -FilePath C:\Services.txt -Width 30 
PS> Get-Content C:\Services.txt
Status   Name               DisplayName
------   -----              -----------
Stopped  AJRouter           Al
```

## Conclusion

![out-file](https://adamtheautomator.com/wp-content/uploads/2022/08/out-file-1024x576.jpg)

Out-File

In a real-world scenario, this cmdlet works but there are better ways to store output to a file.

This cmdlet provides no real options to manipulate the output. It simply saves the output exactly as shown in the console. This cmdlet is similar to a PowerShell transcript that just writes everything directly to a text file.

The `Add-Content` or `Set-Content` cmdlets will always have more flexibility but if you need a quick way to get the PowerShell output to a file, `Out-File` is the way to go.

**_Related: [Set-Content: The PowerShell Way to Write to a File](https://adamtheautomator.com/powershell-write-to-file/)_**

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fout-file%2F&text=Redirect%20PowerShell%20Output%20to%20a%20File%20with%20Out-File%3A%20A%20Complete%20Guide)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fout-file%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fout-file%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
