ErrorView.ps1xml
<?xml version="1.0" encoding="utf-8" ?> <Configuration> <ViewDefinitions> <View> <Name>ErrorInstance</Name> <OutOfBand /> <ViewSelectedBy> <TypeName>System.Management.Automation.ErrorRecord</TypeName> </ViewSelectedBy> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <ExpressionBinding> <ScriptBlock>Write-NativeCommandError $_</ScriptBlock> </ExpressionBinding> <ExpressionBinding> <ScriptBlock> <![CDATA[ if ($formatter = Get-Command "ConvertTo-$($global:ErrorView -replace "View")ErrorView" -ListImported -ErrorAction Ignore -ParameterName InputObject -ParameterType [System.Management.Automation.ErrorRecord]) { &@($formatter)[0] $_ } else { ConvertTo-NormalErrorView $_ } ]]> </ScriptBlock> </ExpressionBinding> </CustomItem> </CustomEntry> </CustomEntries> </CustomControl> </View> </ViewDefinitions> </Configuration> |