Powershell 从Get ChildItem仅获取叶节点
我只想从Powershell 从Get ChildItem仅获取叶节点,powershell,powershell-3.0,Powershell,Powershell 3.0,我只想从Get ChildItem中筛选出叶节点(文件夹),这些叶节点中不包含任何其他文件夹 以下是我当前的查询: Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" 您需要另一个筛选器来确定文件夹中是否有任何内容: Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName) } 您需要另一
Get ChildItem
中筛选出叶节点(文件夹),这些叶节点中不包含任何其他文件夹
以下是我当前的查询:
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*"
您需要另一个筛选器来确定文件夹中是否有任何内容:
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName) }
您需要另一个筛选器来确定文件夹中是否有任何内容:
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName) }
他在正确的路径上,但是在第二个Get ChildItem命令中忘记了-Directory
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName -Directory) }
注意:如果要查找隐藏文件夹,则必须对下一行中的两个Get ChildItem命令使用-Force 他在正确的路径上,但是在第二个Get ChildItem命令中忘记了-Directory
Get-ChildItem -Recurse -Directory -Exclude "*SubStr*" | Where-Object { -not (Get-ChildItem $_.FullName -Directory) }
注意:如果要查找隐藏文件夹,则必须对下一行中的两个Get ChildItem命令使用-Force
Get ChildItem-Recurse-Directory-Exclude“*SubStr*”|?{$$.psiscontainer}
Get ChildItem-Recurse-Directory-Exclude“*SubStr*”|?{$.psiscontainer}不是100%正确,但谢谢你给我指明了正确的方向。不是100%正确,但是谢谢你给我指出了正确的方向。请编辑更多信息。不鼓励只编写代码和“试试这个”答案,因为它们不包含可搜索的内容,也不解释为什么有人应该“试试这个”。我们在这里努力成为一个知识资源。请编辑更多信息。不鼓励只编写代码和“试试这个”答案,因为它们不包含可搜索的内容,也不解释为什么有人应该“试试这个”。我们努力成为知识的源泉。