Format a list that can contain other lists in Powershell
I want to output a list can contain other lists in Powershell so that every list is displayed in a line of its own. I currently use -property SyncRoot but that gives empty lines and unnecessary words in the output. Sample code:
PS H:\> $l = @(1,2)
PS H:\> $l += ,@(3,4,5)
PS H:\> $l += ,@(23,42)
PS H:\> format-list -inputobject 开发者_开发问答$l -property SyncRoot
1
2
SyncRoot : {3, 4, 5}
SyncRoot : {23, 42}
But I want the output to look like this:
1
2
{3, 4, 5}
{23, 42}
PS> [string[]]$u = $l = @(1,2) + @(3,4,5),@(23,42)
PS> $u
1
2
3 4 5
23 42
精彩评论