Prerequisites
Steps to reproduce
Opening this on behalf of a customer.
- Create a simple dummy PowerShell module (e.g: error-test.psm1), containing this:
Function Test-Error {
$errorMessage = "Line1`r`nLine2`r`n"
Write-Error -Message "`r`n$errorMessage"
}
Function Test-ErrorWrapper {
Test-Error
}
- Import the module in your current PowerShell session:
Import-Module <path to>\error-test.psm1
- Run the
Test-Error function, everything works as expected.
- Run the
Test-ErrorWrapper (just calling the other function) & the error message is displayed without any line breaks.
Note: if you change $ErrorView to NormalView then the line breaks are displayed as expected, along with the "full error details".
Expected behavior
Test-Error displays the message as intended.
PS C:\> Test-Error
Test-Error:
Line1
Line2
Actual behavior
Test-ErrorWrapper displays the message without the line breaks, everything on a single line.
PS C:\> Test-ErrorWrapper
Test-Error: Line1 Line2
Error details
No response
Environment data
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.4
PSEdition Core
GitCommitId 7.4.4
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
When $ErrorView is ConciseView (by default in PowerShell 7+), line breaks are missing/removed:

When $ErrorView is set to NormalView, the line breaks are there & the message is displayed as intended, along with the "full error details".

Prerequisites
Steps to reproduce
Opening this on behalf of a customer.
Import-Module <path to>\error-test.psm1Test-Errorfunction, everything works as expected.Test-ErrorWrapper(just calling the other function) & the error message is displayed without any line breaks.Note: if you change
$ErrorViewtoNormalViewthen the line breaks are displayed as expected, along with the "full error details".Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
When

$ErrorViewisConciseView(by default in PowerShell 7+), line breaks are missing/removed:When

$ErrorViewis set toNormalView, the line breaks are there & the message is displayed as intended, along with the "full error details".