Prerequisites
Steps to reproduce
According to about_Redirection:
Using the redirection operator with a file target is functionally equivalent to piping to Out-File with no extra parameters.
The documentation for Out-File -NoNewLine says:
No newline is added after the last output string.
Which means Out-File does normally add a newline. And this is what you see in PowerShell 7.3.10. If the output does not end in a newline, Out-File and file redirection add a newline. But in PowerShell 7.4.0, with file redirection that newline is no longer added.
To make this easy to repro you'll want a native executable that outputs character data but no newline (LF or CR/LF) at the end. Here's a C# program that does that. You don't have to use this program to repro the problem. It just helps.
namespace Example;
internal class Program
{
static void Main()
{
Console.Write("Hello"); // Note that it's not WriteLine()
}
}
This appears to be related to the PR: #17857 by @SeeminglyScience that was added in preview 4
Appears to be related to #20747 and #20808.
Expected behavior
# See "Steps to reproduce" for source code for Hello.exe
PS> .\Hello.exe >x.txt
PS> (Get-Content x.txt -Raw).EndsWith([System.Environment]::NewLine)
True
Actual behavior
# See "Steps to reproduce" for source code for Hello.exe
PS> .\Hello.exe >x.txt
PS> (Get-Content x.txt -Raw).EndsWith([System.Environment]::NewLine)
False
Error details
Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
7.3.10

7.4.0

Prerequisites
Steps to reproduce
According to about_Redirection:
The documentation for Out-File
-NoNewLinesays:Which means
Out-Filedoes normally add a newline. And this is what you see in PowerShell 7.3.10. If the output does not end in a newline,Out-Fileand file redirection add a newline. But in PowerShell 7.4.0, with file redirection that newline is no longer added.To make this easy to repro you'll want a native executable that outputs character data but no newline (LF or CR/LF) at the end. Here's a C# program that does that. You don't have to use this program to repro the problem. It just helps.
This appears to be related to the PR: #17857 by @SeeminglyScience that was added in preview 4
Appears to be related to #20747 and #20808.
Expected behavior
Actual behavior
Error details
N/AEnvironment data
Visuals
7.3.10
7.4.0