diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs index 50b683553..6771c91c2 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -879,7 +879,7 @@ namespace System.Management.Automation.Runspaces $prefix = '' $newline = [Environment]::Newline - if ($myinv -and $myinv.ScriptName -or $_.CategoryInfo.Category -eq 'ParserError') { + if ($myinv -and $myinv.ScriptName -or $myinv.ScriptLineNumber -gt 1 -or $_.CategoryInfo.Category -eq 'ParserError') { if ($myinv.ScriptName) { $posmsg = ""${resetcolor}$($myinv.ScriptName)${newline}"" }