开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜