Gordon
Gordon

Reputation: 6873

CIM_LogicalDisk enumerations

Can someone point me to a reference on the enumerations of DriveType & MediaType for CIM_LogicalDisk? I am pretty sure DriveType is the same as when using WMI and Win32_LogicalDisk, but I can't find any helpful info on the MediaType enumeration.

Upvotes: 0

Views: 351

Answers (2)

Theo
Theo

Reputation: 61178

I found this for you:

DriveType enum:

Value    Meaning
--------------------------
0        Unknown
1        No Root Directory
2        Removable Disk
3        Local Disk
4        Network Drive
5        Compact Disc
6        RAM Disk

MediaType enum:

Type of media currently present in the logical drive. This value will be one of the values of the MEDIA_TYPE enumeration defined in Winioctl.h. The value may not be exact for removable drives if currently there is no media in the drive.

See _MEDIA_TYPE Enumeration of Ntdddisk.h.

Upvotes: 2

user6811411
user6811411

Reputation:

To get a verbose output of DriveType, insert your own [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

Sample output

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

Upvotes: 0

Related Questions