Skip to content

Commit

Permalink
Update notes on redirection of native commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed Nov 29, 2023
1 parent b7df9e2 commit d686b6f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains how to redirect output from PowerShell to text files.
Locale: en-US
ms.date: 09/29/2023
ms.date: 11/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_redirection?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Redirection
Expand All @@ -26,9 +26,14 @@ You can use the following methods to redirect output:
- Use the `Tee-Object` cmdlet, which sends command output to a text file and
then sends it to the pipeline.

- Use the PowerShell redirection operators. Using the redirection operator with
a file target is functionally equivalent to piping to `Out-File` with no
extra parameters.
- Use the PowerShell redirection operators. Redirecting the output of a
PowerShell command (cmdlet, function, script) using the redirection operator
(`>`) is functionally equivalent to piping to `Out-File` with no extra
parameters.

PowerShell 7.4 changed the behavior of the redirection operators when used to
redirect the **stdout** stream of a native command. For more information, see
[Example #7](#example-7-redirecting-binary-data-from-a-native-command).

For more information about streams, see [about_Output_Streams][04].

Expand Down
11 changes: 7 additions & 4 deletions reference/7.4/Microsoft.PowerShell.Utility/Out-File.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 07/27/2023
ms.date: 11/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Out-File
Expand Down Expand Up @@ -34,9 +34,12 @@ Out-File [[-Encoding] <Encoding>] -LiteralPath <string> [-Append] [-Force] [-NoC
The `Out-File` cmdlet sends output to a file. It implicitly uses PowerShell's formatting system to
write to the file. The file receives the same display representation as the terminal. This means
that the output may not be ideal for programmatic processing unless all input objects are strings.
When you need to specify parameters for the output, use `Out-File` rather than the redirection
operator (`>`). For more information about redirection, see
[about_Redirection](../Microsoft.PowerShell.Core/About/about_Redirection.md).

When you use the redirection operator (`>`) to redirect output to a file, internally, PowerShell
adds `Out-File` to the end of the pipeline. If you need to change how PowerShell writes to the file,
use `Out-File` with parameters rather than the redirection operator (`>`). PowerShell 7.4 also
changed the behavior when redirecting from a native command. For more information about redirection,
see [about_Redirection](../Microsoft.PowerShell.Core/About/about_Redirection.md).

## EXAMPLES

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: What's New in PowerShell 7.4
description: New features and changes released in PowerShell 7.4
ms.date: 11/16/2023
ms.date: 11/29/2023
---

# What's New in PowerShell 7.4
Expand All @@ -21,6 +21,13 @@ For a complete list of changes, see the [CHANGELOG][15] in the GitHub repository
- `Test-Json` now uses Json.Schema.Net instead of Newtonsoft.Json.Schema. With this change,
`Test-Json` no longer supports the older Draft 4 schemas. ([#18141][18141]) (Thanks @gregsdennis!)
- Output from `Test-Connection` now includes more detailed information about TCP connection tests
- .NET introduced changes that affected `Test-Connection`. The cmdlet now returns error about the
need to use `sudo` on Linux platforms when using a custom buffer size ([#20369][20369])
- Experimental feature [PSNativeCommandPreserveBytePipe][10] is now mainstream. PowerShell now
preserves the byte-stream data when redirecting the **stdout** stream of a native command to a
file or when piping byte-stream data to the stdin stream of a native command.
- Change how relative paths in `Resolve-Path` are handled when using the **RelativeBasePath**
parameter ([#19755][19755]) (Thanks @MartinGC94!)

## Installer updates

Expand Down Expand Up @@ -325,3 +332,4 @@ For more information about the Experimental Features, see [Using Experimental Fe
[20369]: https://github.com/PowerShell/PowerShell/pull/20369
[20371]: https://github.com/PowerShell/PowerShell/pull/20371
[17955]: https://github.com/PowerShell/PowerShell/pull/17955
[19755]: https://github.com/PowerShell/PowerShell/pull/19755

0 comments on commit d686b6f

Please sign in to comment.