尝试检查特定路径中的文件夹是否共享或未使用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。