You can write a function that does the pretty-printing for you. Something like the following might work for your needs:
function pp($a) {
if ($a -eq $null) {
return "Null"
} elseif ($a -is [object[]]) {
$b = @()
foreach ($x in $a) {
$b += (pp $x)
}
$s = "@(" + [string]::Join(",", $b) + ")"
return $s
} else {
return $a
}
}
This has, however still problems with an empty array on the shell (works fine from a .ps1 file, though). Also Hashtables aren't supported, but nested arrays are. Probably still needs some plumbing but might give a general direction.
The @($null, $null)
array seems to be an ugly beast, resisting even comparing it to $null
. Weird.