有人可以指出我对CIM_LogicalDisk的DriveType和MediaType枚举的引用吗?我很确定DriveType与使用WMI和Win32_LogicalDisk时相同,但是找不到关于MediaType枚举的任何有用信息。
答案 0 :(得分:2)
我为您找到了这个
DriveType
枚举:
Value Meaning
--------------------------
0 Unknown
1 No Root Directory
2 Removable Disk
3 Local Disk
4 Network Drive
5 Compact Disc
6 RAM Disk
MediaType
枚举:
逻辑驱动器中当前存在的介质类型。此值将是Winioctl.h中定义的MEDIA_TYPE枚举的值之一。如果当前驱动器中没有介质,则该值对于可移动驱动器可能不正确。
答案 1 :(得分:0)
要获取DriveType的详细输出,请插入自己的[enum]
## Q:\Test\2018\07\27\SO_51558468.ps1
Enum DriveType {
Unknown = 0
NoRootDirectory = 1
RemovableDisk = 2
LocalDisk = 3
NetworkDrive = 4
OpticalDisk = 5
RamDisk = 6
}
# need a calculated property to insert the Name of the enum
Get-WmiObject -Class Win32_logicaldisk |
Select-Object DeviceID,
@{n='DriveTypeVerbose';e={[enum]::GetName([DriveType],$_.DriveType)}},
ProviderName,FreeSpace,Size,VolumeName | Format-Table
Get-WmiObject -Class CIM_logicaldisk | Where DriveType |
Select-Object DeviceID,
@{n='DriveTypeVerbose';e={[enum]::GetName([DriveType],$_.DriveType)}},
ProviderName,FreeSpace,Size,VolumeName | Format-Table
样本输出
DeviceID DriveTypeVerbose ProviderName FreeSpace Size VolumeName
-------- ---------------- ------------ --------- ---- ----------
A: LocalDisk 1049710592 1073737728 RamDisk
C: LocalDisk 926377299968 999176232960 System-HPG1610
D: OpticalDisk
K: NetworkDrive \\xxxxx\c 105826541568 214276501504 System
L: NetworkDrive \\xxxxx\D 1065067708416 2000263573504 Data
Q: NetworkDrive \\yyyyyy\Data 8657271330816 9704357708800 Data
W: NetworkDrive \\xxxxx\Winstall 1065067708416 2000263573504 Data