格式化可包含Powershell中其他列表的列表

格式化可包含Powershell中其他列表的列表,powershell,Powershell,我想输出一个列表,该列表可以包含Powershell中的其他列表,以便每个列表都显示在自己的一行中。我目前使用-property SyncRoot,但这会在输出中产生空行和不必要的单词。 示例代码: 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 :

我想输出一个列表,该列表可以包含Powershell中的其他列表,以便每个列表都显示在自己的一行中。我目前使用-property SyncRoot,但这会在输出中产生空行和不必要的单词。 示例代码:

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}
但我希望输出如下所示:

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