我以为我得到了所有的容器
$containers = Get-ChildItem -path $Path -recurse | ? {$_.psIscontainer -eq $true},但它似乎只返回了我的$Path. 我真的很想$containers包含$Path及其子目录。我试过这个:
$containers = Get-Item -path $Path | ? {$_.psIscontainer -eq $true}
$containers += Get-ChildItem -path $Path -recurse | ? {$_.psIscontainer -eq $true}
但它不允许我这样做。我是不是用Get-ChildItem错了,或者我如何$Path通过将 Get-Item 和 Get-ChildItem 与 -recurse 组合来让 $containers 包含它及其 $subdirectories?