[PowerShell] Display Nested Array in format.ps1xml

Status
Not open for further replies.

Sog

Ars Tribunus Militum
1,575
I'm trying to solve something similar to what is done in this StackOverflow question. I have an object with a nested array. I'd like the default view to be that nested array, but keep the object intact. The StackOverflow OP states they solved their issue, but I haven't been able to locate or come up with the solution. From that post it would seem my challenge is doable. Posts in PowerShell related communities haven't produced any positive or negative responses to my query. Maybe if I branch out into a broader coder audience I'll get lucky. :)

Thank you.
 

Sog

Ars Tribunus Militum
1,575
It's really useful and not all that hard to do. There's a method of controlling it within a function (see the bottom of Get-ServiceNowIncident, but with that method you lose the underlying object. If you use the format.ps1xml method your object stays intact while the displayed format is what you choose (see the bottom of Get-ServiceNowChangeRequest.

If you have Exchange around it's how Get-Mailbox displays 3 or 4 default properties, but if you dig deeper there are dozens available.

It's only hard when you don't know how to reveal the nested object. :facepalm: A nested string is easy enough as is parts of the nested array. I just can't crack the entire thing.
 
Status
Not open for further replies.