deetle
deetle

Reputation: 387

How to output an object like '$obj | Out-Default' but in color like 'write-host'

The color for '$obj | Out-Default' is always white. Write-Host lets you select -ForegroundColor * -BackgroundColor. But it doesn't show the object nice.

Test object

$obj = [PSCustomObject]@{ 
                String = "A"
                Num = 6
     }

out-default

String Num
------ ---
A        6

write-host

@{String=A; Num=6}

Upvotes: 2

Views: 131

Answers (1)

deetle
deetle

Reputation: 387

This is not my answer, it is Mathias R. Jessen's.

Use Write-Host in conjunction with Out-String; e.g.:

Write-Host ($obj |Out-String) -ForegroundColor Cyan

Upvotes: 4

Related Questions