所以我有一个查询扫描所有可用的磁盘驱动器:
$Disks = get-wmiobject Win32_LogicalDisk | ? {$_.drivetype -eq '3' -and $_.DeviceID -ne 'c:'} | % {get-psdrive $_.deviceid[0]} | select Root
Foreach ($drive in $Disks)
{
//This tells me if a particular folder is present
$DriveLetter = Test-Path $drive -PathType Container| where-Object {$_.Name -like '*SQL*'}
Write-Host "$driveletter"
}
我希望获得不包含文件和文件夹的驱动器号。
有没有一种简单的方法可以实现这一目标?