Main example
List instances
# All instances of Win32_DiskDrive, with the main properties
Get-CimInstance -ClassName Win32_DiskDrive |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'Model'
'SerialNumber'
@{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
)Examples
Filter with WQL
# WQL filter evaluated by the provider: Availability = 3 (Running/Full Power)
Get-CimInstance -ClassName Win32_DiskDrive -Filter 'Availability = 3' |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'Model'
'SerialNumber'
@{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
)The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.
Decode numeric values
# Lookup table for Availability (values documented by Microsoft)
$availabilityName = @{
1 = 'Other'
2 = 'Unknown'
3 = 'Running/Full Power'
4 = 'Warning'
5 = 'In Test'
6 = 'Not Applicable'
7 = 'Power Off'
8 = 'Off Line'
9 = 'Off Duty'
10 = 'Degraded'
11 = 'Not Installed'
12 = 'Install Error'
13 = 'Power Save - Unknown'
14 = 'Power Save - Low Power Mode'
15 = 'Power Save - Standby'
16 = 'Power Cycle'
17 = 'Power Save - Warning'
18 = 'Paused'
19 = 'Not Ready'
20 = 'Not Configured'
21 = 'Quiesced'
}
# Lookup table for ConfigManagerErrorCode (values documented by Microsoft)
$configManagerErrorCodeName = @{
0 = 'This device is working properly'
1 = 'This device is not configured correctly'
2 = 'Windows cannot load the driver for this device'
3 = 'The driver for this device might be corrupted, or your…'
4 = 'This device is not working properly'
5 = 'The driver for this device needs a resource that Windows…'
6 = 'The boot configuration for this device conflicts with other…'
7 = 'Cannot filter'
8 = 'The driver loader for the device is missing'
9 = 'This device is not working properly because the controlling…'
10 = 'This device cannot start'
11 = 'This device failed'
12 = 'This device cannot find enough free resources that it can use'
13 = 'Windows cannot verify this device''s resources'
14 = 'This device cannot work properly until you restart your…'
15 = 'This device is not working properly because there is…'
16 = 'Windows cannot identify all the resources this device uses'
17 = 'This device is asking for an unknown resource type'
18 = 'Reinstall the drivers for this device'
19 = 'Failure using the VxD loader'
20 = 'Your registry might be corrupted'
21 = 'System failure: Try changing the driver for this device'
22 = 'This device is disabled'
23 = 'System failure: Try changing the driver for this device'
24 = 'This device is not present, is not working properly, or does…'
25 = 'Windows is still setting up this device'
26 = 'Windows is still setting up this device'
27 = 'This device does not have valid log configuration'
28 = 'The drivers for this device are not installed'
29 = 'This device is disabled because the firmware of the device…'
30 = 'This device is using an Interrupt Request (IRQ) resource…'
31 = 'This device is not working properly because Windows cannot…'
}
Get-CimInstance -ClassName Win32_DiskDrive |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'Model'
'SerialNumber'
@{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName Win32_DiskDrive |
Select-Object -Property @(
'DeviceID'
'Description'
'Status'
'Manufacturer'
'Model'
'SerialNumber'
@{ Name = 'SizeGB'; Expression = { [math]::Round($_.Size / 1GB, 2) } }
)
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_DiskDrive
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Availability# | uint16 | read | Availability and status of the device. Values (21)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BytesPerSector# | uint32 | read | Number of bytes in each sector for the physical disk drive. Example: 512 Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Capabilities# | uint16[] | read | Array of capabilities of the media access device. For example, the device may support random access (3), removable media (7), and automatic cleaning (9). Values (13)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CapabilityDescriptions# | string[] | read | List of more detailed explanations for any of the access device features indicated in the Capabilities array. Note, each entry of this array is related to the entry in the Capabilities array that is located at the same index. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Caption# | string | read | Short description of the object. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CompressionMethod# | string | read | Algorithm or tool used by the device to support compression. This property is inherited from CIM_MediaAccessDevice. The name of the compression algorithm or one of the following values. Values (3)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ConfigManagerErrorCode# | uint32 | read | Windows Configuration Manager error code. Values (32)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ConfigManagerUserConfig# | boolean | read | If True, the device is using a user-defined configuration. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreationClassName# key | string | read | Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DefaultBlockSize# | uint64 | read | Default block size, in bytes, for this device. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description# | string | read | Description of the object. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DeviceID# key | string | read | Unique identifier of the disk drive with other devices on the system. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ErrorCleared# | boolean | read | If True, the error reported in LastErrorCode is now cleared. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ErrorDescription# | string | read | More information about the error recorded in LastErrorCode, and information on any corrective actions that may be taken. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ErrorMethodology# | string | read | Type of error detection and correction supported by this device. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FirmwareRevision# | string | read | Revision for the disk drive firmware that is assigned by the manufacturer. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Index# | uint32 | read | Physical drive number of the given drive. This property is filled by the STORAGE_DEVICE_NUMBER structure returned from the IOCTL_STORAGE_GET_DEVICE_NUMBER control code. A value of 0xffffffff indicates that the given drive does not map to a physical drive. Example: 1 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InstallDate# | datetime | read | Date and time the object was installed. This property does not need a value to indicate that the object is installed. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| InterfaceType# | string | read | Interface type of physical disk drive. The values are: SCSI HDC IDE USB 1394 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LastErrorCode# | uint32 | read | Last error code reported by the logical device. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manufacturer# | string | read | Name of the disk drive manufacturer. Example: "Seagate" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxBlockSize# | uint64 | read | Maximum block size, in bytes, for media accessed by this device. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaxMediaSize# | uint64 | read | Maximum media size, in kilobytes, of media supported by this device. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: kilobytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MediaLoaded# | boolean | read | If True, the media for a disk drive is loaded, which means that the device has a readable file system and is accessible. For fixed disk drives, this property will always be TRUE. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MediaType# | string | read | Type of media used or accessed by this device. Possible values are: Values (4)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MinBlockSize# | uint64 | read | Minimum block size, in bytes, for media accessed by this device. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Model# | string | read | Manufacturer's model number of the disk drive. Example: "ST32171W" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name# | string | read | Label by which the object is known. When subclassed, the property can be overridden to be a key property. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NeedsCleaning# | boolean | read | If True, the media access device needs cleaning. Whether manual or automatic cleaning is possible is indicated in the Capabilities property. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NumberOfMediaSupported# | uint32 | read | Maximum number of media which can be supported or inserted (when the media access device supports multiple individual media). Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Partitions# | uint32 | read | Number of partitions on this physical disk drive that are recognized by the operating system. Example: 2 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PNPDeviceID# | string | read | Windows Plug and Play device identifier of the logical device. Example: "*PNP030b" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PowerManagementCapabilities# | uint16[] | read | Array of the specific power-related capabilities of a logical device. Values (8)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PowerManagementSupported# | boolean | read | If True, the device can be power-managed (can be put into suspend mode, and so on). The property does not indicate that power management features are currently enabled, only that the logical device is capable of power management. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCSIBus# | uint32 | read | SCSI bus number of the disk drive. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCSILogicalUnit# | uint16 | read | SCSI logical unit number (LUN) of the disk drive. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCSIPort# | uint16 | read | SCSI port number of the disk drive. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SCSITargetId# | uint16 | read | SCSI identifier number of the disk drive. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SectorsPerTrack# | uint32 | read | Number of sectors in each track for this physical disk drive. Example: 63 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SerialNumber# | string | read | Number allocated by the manufacturer to identify the physical media. Example: WD-WM3493798728 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Signature# | uint32 | read | Disk identification. This property can be used to identify a shared resource. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Size# | uint64 | read | Size of the disk drive. It is calculated by multiplying the total number of cylinders, tracks in each cylinder, sectors in each track, and bytes in each sector. For more information about using uint64 values in scripts, see Scripting in WMI. Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Status# | string | read | Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states. Values are: Values (12)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StatusInfo# | uint16 | read | State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used. Values (5)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemCreationClassName# key | string | read | Value of the scoping computer's CreationClassName property. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SystemName# key | string | read | Name of the scoping system. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TotalCylinders# | uint64 | read | Total number of cylinders on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Example: 657 For more information about using uint64 values in scripts, see Scripting in WMI. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TotalHeads# | uint32 | read | Total number of heads on the disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TotalSectors# | uint64 | read | Total number of sectors on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Example: 2649024 For more information about using uint64 values in scripts, see Scripting in WMI. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TotalTracks# | uint64 | read | Total number of tracks on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Example: 42048 For more information about using uint64 values in scripts, see Scripting in WMI. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TracksPerCylinder# | uint32 | read | Number of tracks in each cylinder on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Example: 64 Code |
Remarks
Physical hard disk drives are the primary storage medium for information in any computing environment. Although organizations often use devices such as tape drives and compact disc drives for archiving data, these devices are not suited for day-to-day storage of user data. Only physical hard disks offer the speed and ease of use required for storing data and for running applications and the operating system.
To efficiently manage data, it is important to have a detailed inventory of all your physical disks, their capabilities, and their capacities. You can use the Win32_DiskDrive class to derive this type of inventory.
Any interface to a Windows physical disk drive is a descendant (or member) of this class. The features of the disk drive seen through this object correspond to the logical and management characteristics of the drive. In some cases, this may not reflect the actual physical characteristics of the device. Any object based on another logical device would not be a member of this class.
For security reasons, a user connecting from a remote computer must have the SC_MANAGER_CONNECT privilege enabled to be able to enumerate this class. For more information, see Service Security and Access Rights.
The Win32_DiskDrive class is derived from CIM_DiskDrive which derives from CIM_MediaAccessDevice. The CIM_MediaAccessDevice class derives from CIM_LogicalDevice.
Inheritance
Superclass chain
- CIM_ManagedSystemElement
- CIM_LogicalElement
- CIM_LogicalDevice
- CIM_MediaAccessDevice
- CIM_DiskDrive
- Win32_DiskDrive
Known subclasses
No known subclass.
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- Provider
- CIMWin32
- MOF file
- CIMWin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
Dynamic Provider("CIMWin32") UUID("{8502C4B2-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.