1

我执行以下操作来检查远程计算机上的本地驱动器/分区:

Get-WmiObject -Class Win32_Share -ComputerName SERVERNAME -Filter "Description='Default share'"

但该命令还返回 CD-rom 等。是否有仅返回磁盘/分区的命令?

4

3 回答 3

3
Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" | 
Foreach-Object {$_.DeviceID}
于 2012-05-10T12:18:14.770 回答
1

试试这个:

Get-WMIObject Win32_DiskPartition  -computername remotecomp |

ForEach-Object {
$info = @{}
$info.Disk = $_.DiskIndex
$info.Partition = $_.Index 
$info.DriveLetter = $_.psbase.GetRelated('Win32_LogicalDisk') |     
Select-Object -ExpandProperty DeviceID    
    New-Object PSObject -Property $info
}

$info # contains partions number and unit letter as hashtable
于 2012-05-10T12:04:51.980 回答
0

Get-WmiObject -query "Select * from Win32_DiskPartition"... 也许?

于 2012-05-10T11:33:32.227 回答