CIM_LogicalDevice

The CIM_LogicalDevice is the parent class for all hardware classes. By querying this class, you receive all hardware instances.

Methods

CIM_LogicalDevice has no methods. Inherited methods (Reset and SetPowerState) are not implemented.

Properties

CIM_LogicalDevice returns 18 properties:

'Availability','ConfigManagerErrorCode','ConfigManagerUserConfig',
'CreationClassName','Description','DeviceID','ErrorCleared','ErrorDescription','InstallDate',
'LastErrorCode','Name','PNPDeviceID','PowerManagementCapabilities','PowerManagementSupported',
'Status','StatusInfo','SystemCreationClassName','SystemName'

Unless explicitly marked as WRITEABLE, all properties are read-only.

Availability

UINT16

Availability and status of the device.

May be empty when device drivers do not provide this information.

Availability returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName Availability -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumAvailability
  {
    Other                       = 1
    Unknown                     = 2
    RunningFull_Power           = 3
    Warning                     = 4
    In_Test                     = 5
    Not_Applicable              = 6
    Power_Off                   = 7
    Off_Line                    = 8
    Off_Duty                    = 9
    Degraded                    = 10
    Not_Installed               = 11
    Install_Error               = 12
    Power_Save_Unknown          = 13
    Power_Save_Low_Power_Mode   = 14
    Power_Save_Standby          = 15
    Power_Cycle                 = 16
    Power_Save_Warning          = 17
    Paused                      = 18
    Not_Ready                   = 19
    Not_Configured              = 20
    Quiesced                    = 21
  }

  [EnumAvailability]($this.PSBase.CimInstanceProperties['Availability'].Value)
} -Force

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Availability
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$Availability = @{
  Name = 'AvailabilityText'
  Expression = {
    $value = $_.Availability
    
    switch([int]$value)
      {
        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'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Caption, Availability, $Availability
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$Availability_map = @{
      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'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumAvailability
{
  Other                       = 1
  Unknown                     = 2
  RunningFull_Power           = 3
  Warning                     = 4
  In_Test                     = 5
  Not_Applicable              = 6
  Power_Off                   = 7
  Off_Line                    = 8
  Off_Duty                    = 9
  Degraded                    = 10
  Not_Installed               = 11
  Install_Error               = 12
  Power_Save_Unknown          = 13
  Power_Save_Low_Power_Mode   = 14
  Power_Save_Standby          = 15
  Power_Cycle                 = 16
  Power_Save_Warning          = 17
  Paused                      = 18
  Not_Ready                   = 19
  Not_Configured              = 20
  Quiesced                    = 21
}

ConfigManagerErrorCode

UINT32

Win32 Configuration Manager error code.

ConfigManagerErrorCode returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName ConfigManagerErrorCode -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumConfigManagerErrorCode
  {
    OK                           = 0
    CONFIG_ERROR                 = 1
    CANNOT_LOAD_DRIVER           = 2
    LOW_MEMORY                   = 3
    CORRUPTED_DRIVER             = 4
    RESOURCE_NEEDED              = 5
    BOOTCONFIG_CONFLICT          = 6
    FILTER                       = 7
    LOADER_MISSING               = 8
    FIRMWARE_PROBLEM             = 9
    CANNOT_START                 = 10
    DEVICE_FAILED                = 11
    MISSING_FREE_RESOURCES       = 12
    CANNOT_VERIFY_RESOURCES      = 13
    RESTART_REQUIRED             = 14
    REENUMERATION_PROBLEM        = 15
    MISSING_RESOURCE             = 16
    UNKNOWN_RESOURCE             = 17
    REINSTALL_DRIVER             = 18
    VXD_FAIL                     = 19
    REGISTRY_CORRUPTION          = 20
    DEVICE_REMOVED               = 21
    DEVICE_DISABLED              = 22
    FAILURE                      = 23
    DEVICE_NOT_PRESENT           = 24
    SETUP_IN_PROGRESS            = 25
    SETUP_STILL_IN_PROGRESS      = 26
    NO_LOG_CONFIG                = 27
    DRIVERS_NOT_INSTALLED        = 28
    DISABLED_MISSING_RESOURCES   = 29
    IRQ_CONFLICT                 = 30
    DRIVER_LOAD_FAILURE          = 31
  }

  [EnumConfigManagerErrorCode]($this.PSBase.CimInstanceProperties['ConfigManagerErrorCode'].Value)
} -Force

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property ConfigManagerErrorCode
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$ConfigManagerErrorCode = @{
  Name = 'ConfigManagerErrorCodeText'
  Expression = {
    $value = $_.ConfigManagerErrorCode
    
    switch([int]$value)
      {
        0          {'OK'}
        1          {'CONFIG_ERROR'}
        2          {'CANNOT_LOAD_DRIVER'}
        3          {'LOW_MEMORY'}
        4          {'CORRUPTED_DRIVER'}
        5          {'RESOURCE_NEEDED'}
        6          {'BOOTCONFIG_CONFLICT'}
        7          {'FILTER'}
        8          {'LOADER_MISSING'}
        9          {'FIRMWARE_PROBLEM'}
        10         {'CANNOT_START'}
        11         {'DEVICE_FAILED'}
        12         {'MISSING_FREE_RESOURCES'}
        13         {'CANNOT_VERIFY_RESOURCES'}
        14         {'RESTART_REQUIRED'}
        15         {'REENUMERATION_PROBLEM'}
        16         {'MISSING_RESOURCE'}
        17         {'UNKNOWN_RESOURCE'}
        18         {'REINSTALL_DRIVER'}
        19         {'VXD_FAIL'}
        20         {'REGISTRY_CORRUPTION'}
        21         {'DEVICE_REMOVED'}
        22         {'DEVICE_DISABLED'}
        23         {'FAILURE'}
        24         {'DEVICE_NOT_PRESENT'}
        25         {'SETUP_IN_PROGRESS'}
        26         {'SETUP_STILL_IN_PROGRESS'}
        27         {'NO_LOG_CONFIG'}
        28         {'DRIVERS_NOT_INSTALLED'}
        29         {'DISABLED_MISSING_RESOURCES'}
        30         {'IRQ_CONFLICT'}
        31         {'DRIVER_LOAD_FAILURE'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Caption, ConfigManagerErrorCode, $ConfigManagerErrorCode
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$ConfigManagerErrorCode_map = @{
      0 = 'OK'
      1 = 'CONFIG_ERROR'
      2 = 'CANNOT_LOAD_DRIVER'
      3 = 'LOW_MEMORY'
      4 = 'CORRUPTED_DRIVER'
      5 = 'RESOURCE_NEEDED'
      6 = 'BOOTCONFIG_CONFLICT'
      7 = 'FILTER'
      8 = 'LOADER_MISSING'
      9 = 'FIRMWARE_PROBLEM'
     10 = 'CANNOT_START'
     11 = 'DEVICE_FAILED'
     12 = 'MISSING_FREE_RESOURCES'
     13 = 'CANNOT_VERIFY_RESOURCES'
     14 = 'RESTART_REQUIRED'
     15 = 'REENUMERATION_PROBLEM'
     16 = 'MISSING_RESOURCE'
     17 = 'UNKNOWN_RESOURCE'
     18 = 'REINSTALL_DRIVER'
     19 = 'VXD_FAIL'
     20 = 'REGISTRY_CORRUPTION'
     21 = 'DEVICE_REMOVED'
     22 = 'DEVICE_DISABLED'
     23 = 'FAILURE'
     24 = 'DEVICE_NOT_PRESENT'
     25 = 'SETUP_IN_PROGRESS'
     26 = 'SETUP_STILL_IN_PROGRESS'
     27 = 'NO_LOG_CONFIG'
     28 = 'DRIVERS_NOT_INSTALLED'
     29 = 'DISABLED_MISSING_RESOURCES'
     30 = 'IRQ_CONFLICT'
     31 = 'DRIVER_LOAD_FAILURE'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumConfigManagerErrorCode
{
  OK                           = 0
  CONFIG_ERROR                 = 1
  CANNOT_LOAD_DRIVER           = 2
  LOW_MEMORY                   = 3
  CORRUPTED_DRIVER             = 4
  RESOURCE_NEEDED              = 5
  BOOTCONFIG_CONFLICT          = 6
  FILTER                       = 7
  LOADER_MISSING               = 8
  FIRMWARE_PROBLEM             = 9
  CANNOT_START                 = 10
  DEVICE_FAILED                = 11
  MISSING_FREE_RESOURCES       = 12
  CANNOT_VERIFY_RESOURCES      = 13
  RESTART_REQUIRED             = 14
  REENUMERATION_PROBLEM        = 15
  MISSING_RESOURCE             = 16
  UNKNOWN_RESOURCE             = 17
  REINSTALL_DRIVER             = 18
  VXD_FAIL                     = 19
  REGISTRY_CORRUPTION          = 20
  DEVICE_REMOVED               = 21
  DEVICE_DISABLED              = 22
  FAILURE                      = 23
  DEVICE_NOT_PRESENT           = 24
  SETUP_IN_PROGRESS            = 25
  SETUP_STILL_IN_PROGRESS      = 26
  NO_LOG_CONFIG                = 27
  DRIVERS_NOT_INSTALLED        = 28
  DISABLED_MISSING_RESOURCES   = 29
  IRQ_CONFLICT                 = 30
  DRIVER_LOAD_FAILURE          = 31
}

ConfigManagerUserConfig

BOOL

If $true, the device is using a user-defined configuration.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property ConfigManagerUserConfig

# filtering all instances with ConfigManagerUserConfig set to $true:
Get-CimInstance -ClassName CIM_LogicalDevice | Where-Object ConfigManagerUserConfig -eq $true | Select-Object -Property ConfigManagerUserConfig

CreationClassName

STRING

Name of the class or subclass used in the creation of an instance. When used with other key properties of the class, this property allows all instances of the class and its subclasses to be uniquely identified.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property CreationClassName

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property CreationClassName | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.CreationClassName
  "${Caption}: CreationClassName = $value"
}

Description

STRING

A textual description of the object.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Description

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Description | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.Description
  "${Caption}: Description = $value"
}

DeviceID

STRING

Address or other identifying information to uniquely name the logical device.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property DeviceID

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property DeviceID | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.DeviceID
  "${Caption}: DeviceID = $value"
}

ErrorCleared

BOOL

If $true, the error reported in the LastErrorCode property is now cleared.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property ErrorCleared

# filtering all instances with ErrorCleared set to $true:
Get-CimInstance -ClassName CIM_LogicalDevice | Where-Object ErrorCleared -eq $true | Select-Object -Property ErrorCleared

ErrorDescription

STRING

Free-form string that supplies information about the error recorded in the LastErrorCode property and corrective actions to perform.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property ErrorDescription

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property ErrorDescription | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.ErrorDescription
  "${Caption}: ErrorDescription = $value"
}

InstallDate

DATETIME

Indicates when the object was installed. Lack of a value does not indicate that the object is not installed.

This property is inherited and typically empty.

LastErrorCode

UINT32

Last error code reported by the logical device.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property LastErrorCode

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property LastErrorCode | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.LastErrorCode
  "${Caption}: LastErrorCode = $value"
}

Name

STRING

Label by which the object is known. When subclassed, this property can be overridden to be a key property.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Name

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Name | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.Name
  "${Caption}: Name = $value"
}

PNPDeviceID

STRING

Indicates the Win32 Plug and Play device identifier of the logical device.

Example: “*PNP030b”

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property PNPDeviceID

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property PNPDeviceID | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.PNPDeviceID
  "${Caption}: PNPDeviceID = $value"
}

PowerManagementCapabilities

UINT16 ARRAY

Array of the specific power-related capabilities of a logical device.

Typically, this class instance does not correctly report power management capabilities and returns “Unsupported” even when devices support power management.

PowerManagementSupported

BOOL

If $true, device can be power-managed, for example, a device can be put into suspend mode, and so on. This property does not indicate that power management features are enabled currently, but it does indicate that the logical device is capable of power management.

Typically, this class instance does not correctly report power management capabilities and always returns $false or nothing.

Status

STRING MAX 10 CHAR

Current status of an object. Various operational and nonoperational statuses can be defined.

Available values:

'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Status

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Status | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.Status
  "${Caption}: Status = $value"
}

StatusInfo

UINT16

State of the logical device. If this property does not apply to the logical device, the value 5 (“Not Applicable”) should be used.

May be empty when device drivers do not provide this information.

StatusInfo returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use Update-Type

Update-Type tells PowerShell how to interpret the property. This command needs to be executed only once per PowerShell session:

Update-TypeData -MemberName StatusInfo -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumStatusInfo
  {
    Other            = 1
    Unknown          = 2
    Enabled          = 3
    Disabled         = 4
    Not_Applicable   = 5
  }

  [EnumStatusInfo]($this.PSBase.CimInstanceProperties['StatusInfo'].Value)
} -Force

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property StatusInfo
Use Select-Object

Select-Object supports calculated properties. When you submit a hashtable, PowerShell dynamically calculates the result:

$StatusInfo = @{
  Name = 'StatusInfoText'
  Expression = {
    $value = $_.StatusInfo
    
    switch([int]$value)
      {
        1          {'Other'}
        2          {'Unknown'}
        3          {'Enabled'}
        4          {'Disabled'}
        5          {'Not Applicable'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property Caption, StatusInfo, $StatusInfo
Use a PowerShell Hashtable

You can use a PowerShell hashtable to decode numeric values. Use a hashtable like this one:

$StatusInfo_map = @{
      1 = 'Other'
      2 = 'Unknown'
      3 = 'Enabled'
      4 = 'Disabled'
      5 = 'Not Applicable'
}
Use Enum structure

You can cast the raw property values to a new enum type to translate raw numeric values into friendly text. Use an enum like this one:

Enum EnumStatusInfo
{
  Other            = 1
  Unknown          = 2
  Enabled          = 3
  Disabled         = 4
  Not_Applicable   = 5
}

SystemCreationClassName

STRING

The scoping system’s creation class name.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property SystemCreationClassName

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property SystemCreationClassName | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.SystemCreationClassName
  "${Caption}: SystemCreationClassName = $value"
}

SystemName

STRING

The scoping system’s name.

# returning class instances:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property SystemName

# reading property value:
Get-CimInstance -ClassName CIM_LogicalDevice | Select-Object -Property SystemName | Foreach-Object {

  $Caption = $_.Caption
  $value = $_.SystemName
  "${Caption}: SystemName = $value"
}

CDXML Definition

You can turn this WMI class and its methods into PowerShell cmdlets by importing below CDXML file (Cmdlet Definition XML) as a module.

Create CIM_LogicalDevice.cdxml
$folder = "c:\wmi\CIM_LogicalDevice"
$cdxmlPath = Join-Path -Path $folder -ChildPath "CIM_LogicalDevice.cdxml"

# create folder if not present:
$exists = Test-Path -Path $folder
if (!$exists) { $null = New-Item -Path $folder -ItemType Directory }

# write file
$content = @'
<?xml version="1.0" encoding="utf-8"?>


<!--
This file is licensed under 'Attribution 4.0 International' license (https://creativecommons.org/licenses/by/4.0/).

You can free of charge use this code in commercial and non-commercial code, and you can freely modify and adjust the code 
as long as you give appropriate credit to the original author Dr. Tobias Weltner.

This material was published and is maintained here: 

https://powershell.one/wmi/root/cimv2/cim_logicaldevice#cdxml-definition
-->


<PowerShellMetadata xmlns="http://schemas.microsoft.com/cmdlets-over-objects/2009/11">
  <!--referencing the WMI class this cdxml uses-->
  <Class ClassName="Root/CIMV2\CIM_LogicalDevice" ClassVersion="2.0">
    <Version>1.0</Version>
    <!--default noun used by Get-cmdlets and when no other noun is specified. By convention, we use the prefix "WMI" and the base name of the WMI class involved. This way, you can easily identify the underlying WMI class.-->
    <DefaultNoun>WmiLogicalDevice</DefaultNoun>
    <!--define the cmdlets that work with class instances.-->
    <InstanceCmdlets>
      <!--query parameters to select instances. This is typically empty for classes that provide only one instance-->
      <GetCmdletParameters />
      <GetCmdlet>
        <CmdletMetadata Verb="Get" />
        <GetCmdletParameters>
          <QueryableProperties>
            <Property PropertyName="Availability">
              <Type PSType="system.uint16" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ConfigManagerErrorCode">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ConfigManagerUserConfig">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="CreationClassName">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Description">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="DeviceID">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ErrorCleared">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ErrorDescription">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="InstallDate">
              <Type PSType="system.datetime" />
              <MinValueQuery>
                <CmdletParameterMetadata PSName="BeforeInstallDate" />
              </MinValueQuery>
              <MaxValueQuery>
                <CmdletParameterMetadata PSName="AfterInstallDate" />
              </MaxValueQuery>
            </Property>
            <Property PropertyName="LastErrorCode">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Name">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PNPDeviceID">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PowerManagementCapabilities">
              <Type PSType="system.uint16[]" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="PowerManagementSupported">
              <Type PSType="switch" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="Status">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="StatusInfo">
              <Type PSType="system.uint16" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
          </QueryableProperties>
        </GetCmdletParameters>
      </GetCmdlet>
      <!--defining additional cmdlets that modifies instance properties-->
    </InstanceCmdlets>
  </Class>
  <!--defining enumerations-->
  <Enums>
    <Enum EnumName="CIM_LogicalDevice_Enum.Availability" UnderlyingType="system.uint16">
      <Value Name="Other" Value="1" />
      <Value Name="Unknown" Value="2" />
      <Value Name="RunningFullPower" Value="3" />
      <Value Name="Warning" Value="4" />
      <Value Name="InTest" Value="5" />
      <Value Name="NotApplicable" Value="6" />
      <Value Name="PowerOff" Value="7" />
      <Value Name="OffLine" Value="8" />
      <Value Name="OffDuty" Value="9" />
      <Value Name="Degraded" Value="10" />
      <Value Name="NotInstalled" Value="11" />
      <Value Name="InstallError" Value="12" />
      <Value Name="PowerSaveUnknown" Value="13" />
      <Value Name="PowerSaveLowPowerMode" Value="14" />
      <Value Name="PowerSaveStandby" Value="15" />
      <Value Name="PowerCycle" Value="16" />
      <Value Name="PowerSaveWarning" Value="17" />
      <Value Name="Paused" Value="18" />
      <Value Name="NotReady" Value="19" />
      <Value Name="NotConfigured" Value="20" />
      <Value Name="Quiesced" Value="21" />
    </Enum>
    <Enum EnumName="CIM_LogicalDevice_Enum.ConfigManagerErrorCode" UnderlyingType="system.uint32">
      <Value Name="OK" Value="0" />
      <Value Name="CONFIGERROR" Value="1" />
      <Value Name="CANNOTLOADDRIVER" Value="2" />
      <Value Name="LOWMEMORY" Value="3" />
      <Value Name="CORRUPTEDDRIVER" Value="4" />
      <Value Name="RESOURCENEEDED" Value="5" />
      <Value Name="BOOTCONFIGCONFLICT" Value="6" />
      <Value Name="FILTER" Value="7" />
      <Value Name="LOADERMISSING" Value="8" />
      <Value Name="FIRMWAREPROBLEM" Value="9" />
      <Value Name="CANNOTSTART" Value="10" />
      <Value Name="DEVICEFAILED" Value="11" />
      <Value Name="MISSINGFREERESOURCES" Value="12" />
      <Value Name="CANNOTVERIFYRESOURCES" Value="13" />
      <Value Name="RESTARTREQUIRED" Value="14" />
      <Value Name="REENUMERATIONPROBLEM" Value="15" />
      <Value Name="MISSINGRESOURCE" Value="16" />
      <Value Name="UNKNOWNRESOURCE" Value="17" />
      <Value Name="REINSTALLDRIVER" Value="18" />
      <Value Name="VXDFAIL" Value="19" />
      <Value Name="REGISTRYCORRUPTION" Value="20" />
      <Value Name="DEVICEREMOVED" Value="21" />
      <Value Name="DEVICEDISABLED" Value="22" />
      <Value Name="FAILURE" Value="23" />
      <Value Name="DEVICENOTPRESENT" Value="24" />
      <Value Name="SETUPINPROGRESS" Value="25" />
      <Value Name="SETUPSTILLINPROGRESS" Value="26" />
      <Value Name="NOLOGCONFIG" Value="27" />
      <Value Name="DRIVERSNOTINSTALLED" Value="28" />
      <Value Name="DISABLEDMISSINGRESOURCES" Value="29" />
      <Value Name="IRQCONFLICT" Value="30" />
      <Value Name="DRIVERLOADFAILURE" Value="31" />
    </Enum>
    <Enum EnumName="CIM_LogicalDevice_Enum.PowerManagementCapabilities" UnderlyingType="system.uint16">
      <Value Name="Unknown" Value="0" />
      <Value Name="NotSupported" Value="1" />
      <Value Name="Disabled" Value="2" />
      <Value Name="Enabled" Value="3" />
      <Value Name="PowerSavingModesEnteredAutomatically" Value="4" />
      <Value Name="PowerStateSettable" Value="5" />
      <Value Name="PowerCyclingSupported" Value="6" />
      <Value Name="TimedPowerOnSupported" Value="7" />
    </Enum>
    <Enum EnumName="CIM_LogicalDevice_Enum.StatusInfo" UnderlyingType="system.uint16">
      <Value Name="Other" Value="1" />
      <Value Name="Unknown" Value="2" />
      <Value Name="Enabled" Value="3" />
      <Value Name="Disabled" Value="4" />
      <Value Name="NotApplicable" Value="5" />
    </Enum>
  </Enums>
</PowerShellMetadata>
'@ | Set-Content -LiteralPath $cdxmlPath -Encoding UTF8

# import module
Import-Module -Name $cdxmlPath -Force -Verbose

# list new cmdlets
Get-Command -Module "CIM_LogicalDevice"

Type Extensions for PowerShell

You can automatically improve properties of class instances by using a types.ps1xml file.

Create CIM_LogicalDevice.Types.ps1xml
$folder = "c:\wmi\CIM_LogicalDevice"
$typesPath = Join-Path -Path $folder -ChildPath "CIM_LogicalDevice.Types.ps1xml"

# create folder if not present:
$exists = Test-Path -Path $folder
if (!$exists) { $null = New-Item -Path $folder -ItemType Directory }

# write file
$content = @'
<?xml version="1.0" encoding="utf-8"?>


<!--
This file is licensed under 'Attribution 4.0 International' license (https://creativecommons.org/licenses/by/4.0/).

You can free of charge use this code in commercial and non-commercial code, and you can freely modify and adjust the code 
as long as you give appropriate credit to the original author Dr. Tobias Weltner.

This material was published and is maintained here: 

https://powershell.one/wmi/root/cimv2/cim_logicaldevice#typesps1xml-file
-->


<Types>
  <Type>
    <!--@

            Applicable type. This type is produced by Get-CimInstance. 
            To extend instances produced by Get-WmiObject, change the type name to: 

            System.Management.ManagementObject#root/cimv2\CIM_LogicalDevice

        @-->
    <Name>Microsoft.Management.Infrastructure.CimInstance#Root/CIMV2/CIM_LogicalDevice</Name>
    <Members>
      <ScriptProperty>
        <Name>Availability</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.CIM_LogicalDevice_Enum.Availability]($this.PSBase.CimInstanceProperties['Availability'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>ConfigManagerErrorCode</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.CIM_LogicalDevice_Enum.ConfigManagerErrorCode]($this.PSBase.CimInstanceProperties['ConfigManagerErrorCode'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>PowerManagementCapabilities</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.CIM_LogicalDevice_Enum.PowerManagementCapabilities]($this.PSBase.CimInstanceProperties['PowerManagementCapabilities'].Value)</GetScriptBlock>
      </ScriptProperty>
      <ScriptProperty>
        <Name>StatusInfo</Name>
        <!--casting raw content to a enum. This translates numeric values to friendly text while leaving the original property value untouched:-->
        <GetScriptBlock>[Microsoft.PowerShell.Cmdletization.GeneratedTypes.CIM_LogicalDevice_Enum.StatusInfo]($this.PSBase.CimInstanceProperties['StatusInfo'].Value)</GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
</Types>
'@ | Set-Content -LiteralPath $typesPath -Encoding UTF8

# import type definition
Update-TypeData -PrependPath $typesPath

Note: CIM_LogicalDevice.Types.ps1xml is using enumerations defined in ClassName.cdxml which are available only when you imported the .cdxml file via Import-Module.

Or, you can manually update the PowerShell type database using Update-TypeData.

View Update-TypeData commands for CIM_LogicalDevice properties
Update-TypeData -MemberName Availability -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumAvailability
  {
    Other                       = 1
    Unknown                     = 2
    RunningFull_Power           = 3
    Warning                     = 4
    In_Test                     = 5
    Not_Applicable              = 6
    Power_Off                   = 7
    Off_Line                    = 8
    Off_Duty                    = 9
    Degraded                    = 10
    Not_Installed               = 11
    Install_Error               = 12
    Power_Save_Unknown          = 13
    Power_Save_Low_Power_Mode   = 14
    Power_Save_Standby          = 15
    Power_Cycle                 = 16
    Power_Save_Warning          = 17
    Paused                      = 18
    Not_Ready                   = 19
    Not_Configured              = 20
    Quiesced                    = 21
  }

  [EnumAvailability]($this.PSBase.CimInstanceProperties['Availability'].Value)
} -Force

Update-TypeData -MemberName ConfigManagerErrorCode -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumConfigManagerErrorCode
  {
    OK                           = 0
    CONFIG_ERROR                 = 1
    CANNOT_LOAD_DRIVER           = 2
    LOW_MEMORY                   = 3
    CORRUPTED_DRIVER             = 4
    RESOURCE_NEEDED              = 5
    BOOTCONFIG_CONFLICT          = 6
    FILTER                       = 7
    LOADER_MISSING               = 8
    FIRMWARE_PROBLEM             = 9
    CANNOT_START                 = 10
    DEVICE_FAILED                = 11
    MISSING_FREE_RESOURCES       = 12
    CANNOT_VERIFY_RESOURCES      = 13
    RESTART_REQUIRED             = 14
    REENUMERATION_PROBLEM        = 15
    MISSING_RESOURCE             = 16
    UNKNOWN_RESOURCE             = 17
    REINSTALL_DRIVER             = 18
    VXD_FAIL                     = 19
    REGISTRY_CORRUPTION          = 20
    DEVICE_REMOVED               = 21
    DEVICE_DISABLED              = 22
    FAILURE                      = 23
    DEVICE_NOT_PRESENT           = 24
    SETUP_IN_PROGRESS            = 25
    SETUP_STILL_IN_PROGRESS      = 26
    NO_LOG_CONFIG                = 27
    DRIVERS_NOT_INSTALLED        = 28
    DISABLED_MISSING_RESOURCES   = 29
    IRQ_CONFLICT                 = 30
    DRIVER_LOAD_FAILURE          = 31
  }

  [EnumConfigManagerErrorCode]($this.PSBase.CimInstanceProperties['ConfigManagerErrorCode'].Value)
} -Force

Update-TypeData -MemberName StatusInfo -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_logicaldevice" -MemberType ScriptProperty  -Value {
  Enum EnumStatusInfo
  {
    Other            = 1
    Unknown          = 2
    Enabled          = 3
    Disabled         = 4
    Not_Applicable   = 5
  }

  [EnumStatusInfo]($this.PSBase.CimInstanceProperties['StatusInfo'].Value)
} -Force

Note: CIM_LogicalDevice.Types.ps1xml is using enumerations defined in ClassName.cdxml which are available only when you imported the .cdxml file via Import-Module.

Requirements

To use CIM_LogicalDevice, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

CIM_LogicalDevice was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

CIM_LogicalDevice lives in the namespace root/cimv2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

CIM_LogicalDevice is implemented in CIMWin32.dll and defined in CIMWin32.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\CIMWin32.mof