我执行以下操作来检查远程计算机上的本地驱动器/分区:
Get-WmiObject -Class Win32_Share -ComputerName SERVERNAME -Filter "Description='Default share'"
但该命令还返回 CD-rom 等。是否有仅返回磁盘/分区的命令?
我执行以下操作来检查远程计算机上的本地驱动器/分区:
Get-WmiObject -Class Win32_Share -ComputerName SERVERNAME -Filter "Description='Default share'"
但该命令还返回 CD-rom 等。是否有仅返回磁盘/分区的命令?
Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Foreach-Object {$_.DeviceID}
试试这个:
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
Get-WmiObject -query "Select * from Win32_DiskPartition"
... 也许?