Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何检查Powershell中的目录是否包含其他目录?_Windows_Powershell_Directory - Fatal编程技术网

Windows 如何检查Powershell中的目录是否包含其他目录?

Windows 如何检查Powershell中的目录是否包含其他目录?,windows,powershell,directory,Windows,Powershell,Directory,我正在powershell中寻找一种简单(如果可能)的方法来检查一个目录是否包含至少一个其他目录 $dir = '.' # specify the directory to investigate $hasAnySubdir = (Get-ChildItem -Force -Directory $dir).Count -gt 0 -Directory(PSv3+)确保Get ChildItem仅枚举子目录,而-Force确保甚至包含隐藏的子目录

我正在powershell中寻找一种简单(如果可能)的方法来检查一个目录是否包含至少一个其他目录

$dir = '.'  # specify the directory to investigate
$hasAnySubdir = (Get-ChildItem -Force -Directory $dir).Count -gt 0
-Directory
(PSv3+)确保
Get ChildItem
仅枚举子目录,而
-Force
确保甚至包含隐藏的子目录