Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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
尝试检查特定路径中的文件夹是否共享或未使用powershell。如果共享,将返回一个真值_Powershell - Fatal编程技术网

尝试检查特定路径中的文件夹是否共享或未使用powershell。如果共享,将返回一个真值

尝试检查特定路径中的文件夹是否共享或未使用powershell。如果共享,将返回一个真值,powershell,Powershell,我的剧本 Get-ChildItem "Test path" | ForEach-Object{ $vari = [bool](Get-WmiObject -Class Win32_Share -Filter "path = 'test path'") echo $vari 请帮助我使用脚本避免重复查询wmi,反转逻辑: $TestPath = 'd:\test path' $AllShares = Get-WmiObject -Class Win32_Share Get-ChildItem

我的剧本

Get-ChildItem "Test path" | ForEach-Object{
$vari = [bool](Get-WmiObject -Class Win32_Share -Filter "path = 'test path'")
echo $vari

请帮助我使用脚本

避免重复查询
wmi
,反转逻辑:

$TestPath = 'd:\test path'
$AllShares = Get-WmiObject -Class Win32_Share
Get-ChildItem $TestPath -Directory <#-Recurse<##> -Force -ErrorAction SilentlyContinue | 
    ForEach-Object{
        $vari = $_.FullName -in $AllShares.Path
        if (<#$true -or <##> $vari) { '{0,-6}{1}' -f $vari, $_.FullName }
}
$TestPath='d:\TestPath'
$AllShares=获取WmiObject-类Win32\u共享

Get ChildItem$TestPath-目录请在问题中添加更多说明,在标题中添加更少说明。脚本的问题是什么?“请帮助我”没有给我们太多的工作。如果你总是过滤基本路径,为什么要使用foreach,或者如果检查只针对ome路径,为什么要使用childitem。