Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,11 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
CustomControl.Create(outOfBand: true)
.StartEntry()
.AddScriptBlockExpressionBinding(@"
$errorColor = ''
$commandPrefix = ''
if (@('NativeCommandErrorMessage','NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView','DetailedView') -notcontains $ErrorView)
{
$myinv = $_.InvocationInfo
$errorColor = ''
if ($Host.UI.SupportsVirtualTerminal) {
$errorColor = $PSStyle.Formatting.Error
}
Expand Down Expand Up @@ -1070,10 +1071,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
}
}

if ($commandPrefix)
{
$errorColor + $commandPrefix
}
$errorColor + $commandPrefix
")
.AddScriptBlockExpressionBinding(@"
Set-StrictMode -Off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@ Describe 'Get-Error tests' -Tag CI {
}
}
}

It 'Get-Error works with strict mode' {
$out = pwsh -noprofile -command 'Set-StrictMode -Version Latest; $PSStyle.OutputRendering = "PlainText"; 1/0; Get-Error' | Out-String
$out | Should -Match "Message : Attempted to divide by zero."
}
}