如何通过 PowerShell 中的给定字符加入 Get-ChildItem 的结果?

How can I join the result of Get-ChildItem by a given character in PowerShell?

我最近问 如何 join ls 的结果,我试图将其用于 Get-ChildItem 返回的结果,但没有成功。

我正在尝试 join 结果的命令(比方说 -)是:

Get-ChildItem -Path . -Filter bin -Recurse | where {$_.psiscontainer} | gci -Filter *test*.dll -Recurse | select {$_.FullName}

非常感谢任何帮助。

您需要扩展 FullName 属性 以便您可以连接字符串而不是对象:

(Get-ChildItem -Path . -Filter bin -Recurse | where {$_.psiscontainer} | gci -Filter *test*.dll -Recurse | select -ExpandProperty FullName) -join ' - '