Win32_PhysicalMedia

The Win32_PhysicalMedia class represents any type of documentation or storage medium, such as tapes, CD ROMs, and so on. To obtain the characteristics of the media in a CD drive, such as whether it...

The Win32_PhysicalMedia class represents any type of documentation or storage medium, such as tapes, CD ROMs, and so on. To obtain the characteristics of the media in a CD drive, such as whether it is writeable, use Win32_CDROMDrive and the Capabilities property.

Methods

Win32_PhysicalMedia has no methods.

Properties

Win32_PhysicalMedia returns 23 properties:

'Capacity','Caption','CleanerMedia','CreationClassName','Description','HotSwappable',
'InstallDate','Manufacturer','MediaDescription','MediaType','Model','Name','OtherIdentifyingInfo',
'PartNumber','PoweredOn','Removable','Replaceable','SerialNumber','SKU','Status','Tag','Version',
'WriteProtectOn'

Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:

Get-CimInstance -ClassName Win32_PhysicalMedia -Property *

Most WMI classes return one or more instances.

When Get-CimInstance returns no result, then apparently no instances of class Win32_PhysicalMedia exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

Capacity

UINT64 “BYTES”

Number of bytes that can be read from or written to this physical media component. This property does not apply to “Hard Copy” or cleaner media. Data compression should not be assumed as it would increase the value of this property. For tapes, it should be assumed that no filemarks or blank space areas are recorded on the media.

For more information about using uint64 values in scripts, see Scripting in WMI.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Capacity

Caption

STRING

Short, one-line textual description of the object.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Caption

CleanerMedia

BOOLEAN

If TRUE, the physical media is used for cleaning purposes and not data storage.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, CleanerMedia

CreationClassName

STRING

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

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, CreationClassName

Description

STRING

Textual description of the object.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Description

HotSwappable

BOOLEAN

If TRUE, this physical media component can be replaced with a physically different but equivalent one while the containing package has the power applied. For example, a fan component may be designed to be hot-swapped. All components that can be hot-swapped are inherently removable and replaceable.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, HotSwappable

InstallDate

DATETIME

When the object was installed. This property does not require a value to indicate that the object is installed.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, InstallDate

Manufacturer

STRING

Name of the organization responsible for producing the physical element. This can be the entity from whom the element is purchased, but this is not necessarily the case as this information is contained in the Vendor property.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Manufacturer

MediaDescription

STRING

Additional detail related to the MediaType property. For example, if MediaType has the value 3 (QIC Cartridge) the MediaDescription property can indicate whether the tape is wide or quarter inch.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, MediaDescription

MediaType

UINT16

The type of the media, as an enumerated integer. The MediaDescription property provides a more explicit definition of the media type.

The following list lists the possible values.

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

Use a PowerShell Hashtable
$MediaType_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Tape Cartridge'
      3 = 'QIC Cartridge'
      4 = 'AIT Cartridge'
      5 = 'DTF Cartridge'
      6 = 'DAT Cartridge'
      7 = '8mm Tape Cartridge'
      8 = '19mm Tape Cartridge'
      9 = 'DLT Cartridge'
     10 = 'Half-Inch Magnetic Tape Cartridge'
     11 = 'Cartridge Disk'
     12 = 'JAZ Disk'
     13 = 'ZIP Disk'
     14 = 'SyQuest Disk'
     15 = 'Winchester Removable Disk'
     16 = 'CD-ROM'
     17 = 'CD-ROM/XA'
     18 = 'CD-I'
     19 = 'CD Recordable'
     20 = 'WORM'
     21 = 'Magneto-Optical'
     22 = 'DVD'
     23 = 'DVD+RW'
     24 = 'DVD-RAM'
     25 = 'DVD-ROM'
     26 = 'DVD-Video'
     27 = 'Divx'
     28 = 'Floppy/Diskette'
     29 = 'Hard Disk'
     30 = 'Memory Card'
     31 = 'Hard Copy'
     32 = 'Clik Disk'
     33 = 'CD-RW'
     34 = 'CD-DA'
     35 = 'CD+'
     36 = 'DVD Recordable'
     37 = 'DVD-RW'
     38 = 'DVD-Audio'
     39 = 'DVD-5'
     40 = 'DVD-9'
     41 = 'DVD-10'
     42 = 'DVD-18'
     43 = 'Magneto-Optical Rewriteable'
     44 = 'Magneto-Optical Write Once'
     45 = 'Magneto-Optical Rewriteable (LIMDOW)'
     46 = 'Phase Change Write Once'
     47 = 'Phase Change Rewriteable'
     48 = 'Phase Change Dual Rewriteable'
     49 = 'Ablative Write Once'
     50 = 'Near Field Recording'
     51 = 'MiniQic'
     52 = 'Travan'
     53 = '8mm Metal Particle'
     54 = '8mm Advanced Metal Evaporate'
     55 = 'NCTP'
     56 = 'LTO Ultrium'
     57 = 'LTO Accelis'
     58 = '9 Track Tape'
     59 = '18 Track Tape'
     60 = '36 Track Tape'
     61 = 'Magstar 3590'
     62 = 'Magstar MP'
     63 = 'D2 Tape'
     64 = 'Tape - DST Small'
     65 = 'Tape - DST Medium'
     66 = 'Tape - DST Large'
}
Use a switch statement
switch([int]$value)
{
  0          {'Unknown'}
  1          {'Other'}
  2          {'Tape Cartridge'}
  3          {'QIC Cartridge'}
  4          {'AIT Cartridge'}
  5          {'DTF Cartridge'}
  6          {'DAT Cartridge'}
  7          {'8mm Tape Cartridge'}
  8          {'19mm Tape Cartridge'}
  9          {'DLT Cartridge'}
  10         {'Half-Inch Magnetic Tape Cartridge'}
  11         {'Cartridge Disk'}
  12         {'JAZ Disk'}
  13         {'ZIP Disk'}
  14         {'SyQuest Disk'}
  15         {'Winchester Removable Disk'}
  16         {'CD-ROM'}
  17         {'CD-ROM/XA'}
  18         {'CD-I'}
  19         {'CD Recordable'}
  20         {'WORM'}
  21         {'Magneto-Optical'}
  22         {'DVD'}
  23         {'DVD+RW'}
  24         {'DVD-RAM'}
  25         {'DVD-ROM'}
  26         {'DVD-Video'}
  27         {'Divx'}
  28         {'Floppy/Diskette'}
  29         {'Hard Disk'}
  30         {'Memory Card'}
  31         {'Hard Copy'}
  32         {'Clik Disk'}
  33         {'CD-RW'}
  34         {'CD-DA'}
  35         {'CD+'}
  36         {'DVD Recordable'}
  37         {'DVD-RW'}
  38         {'DVD-Audio'}
  39         {'DVD-5'}
  40         {'DVD-9'}
  41         {'DVD-10'}
  42         {'DVD-18'}
  43         {'Magneto-Optical Rewriteable'}
  44         {'Magneto-Optical Write Once'}
  45         {'Magneto-Optical Rewriteable (LIMDOW)'}
  46         {'Phase Change Write Once'}
  47         {'Phase Change Rewriteable'}
  48         {'Phase Change Dual Rewriteable'}
  49         {'Ablative Write Once'}
  50         {'Near Field Recording'}
  51         {'MiniQic'}
  52         {'Travan'}
  53         {'8mm Metal Particle'}
  54         {'8mm Advanced Metal Evaporate'}
  55         {'NCTP'}
  56         {'LTO Ultrium'}
  57         {'LTO Accelis'}
  58         {'9 Track Tape'}
  59         {'18 Track Tape'}
  60         {'36 Track Tape'}
  61         {'Magstar 3590'}
  62         {'Magstar MP'}
  63         {'D2 Tape'}
  64         {'Tape - DST Small'}
  65         {'Tape - DST Medium'}
  66         {'Tape - DST Large'}
  default    {"$value"}
}
Use Enum structure
Enum EnumMediaType
{
  Unknown                              = 0
  Other                                = 1
  Tape_Cartridge                       = 2
  QIC_Cartridge                        = 3
  AIT_Cartridge                        = 4
  DTF_Cartridge                        = 5
  DAT_Cartridge                        = 6
  _8mm_Tape_Cartridge                  = 7
  _19mm_Tape_Cartridge                 = 8
  DLT_Cartridge                        = 9
  Half_Inch_Magnetic_Tape_Cartridge    = 10
  Cartridge_Disk                       = 11
  JAZ_Disk                             = 12
  ZIP_Disk                             = 13
  SyQuest_Disk                         = 14
  Winchester_Removable_Disk            = 15
  CD_ROM                               = 16
  CD_ROMXA                             = 17
  CD_I                                 = 18
  CD_Recordable                        = 19
  WORM                                 = 20
  Magneto_Optical                      = 21
  DVD                                  = 22
  DVDRW                                = 23
  DVD_RAM                              = 24
  DVD_ROM                              = 25
  DVD_Video                            = 26
  Divx                                 = 27
  FloppyDiskette                       = 28
  Hard_Disk                            = 29
  Memory_Card                          = 30
  Hard_Copy                            = 31
  Clik_Disk                            = 32
  CD_RW                                = 33
  CD_DA                                = 34
  CD                                   = 35
  DVD_Recordable                       = 36
  DVD_RW                               = 37
  DVD_Audio                            = 38
  DVD_5                                = 39
  DVD_9                                = 40
  DVD_10                               = 41
  DVD_18                               = 42
  Magneto_Optical_Rewriteable          = 43
  Magneto_Optical_Write_Once           = 44
  Magneto_Optical_Rewriteable_LIMDOW   = 45
  Phase_Change_Write_Once              = 46
  Phase_Change_Rewriteable             = 47
  Phase_Change_Dual_Rewriteable        = 48
  Ablative_Write_Once                  = 49
  Near_Field_Recording                 = 50
  MiniQic                              = 51
  Travan                               = 52
  _8mm_Metal_Particle                  = 53
  _8mm_Advanced_Metal_Evaporate        = 54
  NCTP                                 = 55
  LTO_Ultrium                          = 56
  LTO_Accelis                          = 57
  _9_Track_Tape                        = 58
  _18_Track_Tape                       = 59
  _36_Track_Tape                       = 60
  Magstar_3590                         = 61
  Magstar_MP                           = 62
  D2_Tape                              = 63
  Tape_DST_Small                       = 64
  Tape_DST_Medium                      = 65
  Tape_DST_Large                       = 66
}

Examples

Use $MediaType_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "MediaType" to friendly text

  Note: to use other properties than "MediaType", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "MediaType" 
# to translate other properties, use their translation table instead
$MediaType_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Tape Cartridge'
      3 = 'QIC Cartridge'
      4 = 'AIT Cartridge'
      5 = 'DTF Cartridge'
      6 = 'DAT Cartridge'
      7 = '8mm Tape Cartridge'
      8 = '19mm Tape Cartridge'
      9 = 'DLT Cartridge'
     10 = 'Half-Inch Magnetic Tape Cartridge'
     11 = 'Cartridge Disk'
     12 = 'JAZ Disk'
     13 = 'ZIP Disk'
     14 = 'SyQuest Disk'
     15 = 'Winchester Removable Disk'
     16 = 'CD-ROM'
     17 = 'CD-ROM/XA'
     18 = 'CD-I'
     19 = 'CD Recordable'
     20 = 'WORM'
     21 = 'Magneto-Optical'
     22 = 'DVD'
     23 = 'DVD+RW'
     24 = 'DVD-RAM'
     25 = 'DVD-ROM'
     26 = 'DVD-Video'
     27 = 'Divx'
     28 = 'Floppy/Diskette'
     29 = 'Hard Disk'
     30 = 'Memory Card'
     31 = 'Hard Copy'
     32 = 'Clik Disk'
     33 = 'CD-RW'
     34 = 'CD-DA'
     35 = 'CD+'
     36 = 'DVD Recordable'
     37 = 'DVD-RW'
     38 = 'DVD-Audio'
     39 = 'DVD-5'
     40 = 'DVD-9'
     41 = 'DVD-10'
     42 = 'DVD-18'
     43 = 'Magneto-Optical Rewriteable'
     44 = 'Magneto-Optical Write Once'
     45 = 'Magneto-Optical Rewriteable (LIMDOW)'
     46 = 'Phase Change Write Once'
     47 = 'Phase Change Rewriteable'
     48 = 'Phase Change Dual Rewriteable'
     49 = 'Ablative Write Once'
     50 = 'Near Field Recording'
     51 = 'MiniQic'
     52 = 'Travan'
     53 = '8mm Metal Particle'
     54 = '8mm Advanced Metal Evaporate'
     55 = 'NCTP'
     56 = 'LTO Ultrium'
     57 = 'LTO Accelis'
     58 = '9 Track Tape'
     59 = '18 Track Tape'
     60 = '36 Track Tape'
     61 = 'Magstar 3590'
     62 = 'Magstar MP'
     63 = 'D2 Tape'
     64 = 'Tape - DST Small'
     65 = 'Tape - DST Medium'
     66 = 'Tape - DST Large'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "MediaType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$MediaType = @{
  Name = 'MediaType'
  Expression = {
    # property is an array, so process all values
    $value = $_.MediaType
    $MediaType_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "MediaType". The latter
# is defined by the hashtable in $MediaType: 
Get-CimInstance -Class Win32_PhysicalMedia | Select-Object -Property Caption, $MediaType

# ...or dump content of property MediaType:
$friendlyValues = Get-CimInstance -Class Win32_PhysicalMedia | 
    Select-Object -Property $MediaType |
    Select-Object -ExpandProperty MediaType

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $MediaType_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_PhysicalMedia" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_PhysicalMedia", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_PhysicalMedia" 
# to translate other properties, use their translation table instead
$MediaType_map = @{
      0 = 'Unknown'
      1 = 'Other'
      2 = 'Tape Cartridge'
      3 = 'QIC Cartridge'
      4 = 'AIT Cartridge'
      5 = 'DTF Cartridge'
      6 = 'DAT Cartridge'
      7 = '8mm Tape Cartridge'
      8 = '19mm Tape Cartridge'
      9 = 'DLT Cartridge'
     10 = 'Half-Inch Magnetic Tape Cartridge'
     11 = 'Cartridge Disk'
     12 = 'JAZ Disk'
     13 = 'ZIP Disk'
     14 = 'SyQuest Disk'
     15 = 'Winchester Removable Disk'
     16 = 'CD-ROM'
     17 = 'CD-ROM/XA'
     18 = 'CD-I'
     19 = 'CD Recordable'
     20 = 'WORM'
     21 = 'Magneto-Optical'
     22 = 'DVD'
     23 = 'DVD+RW'
     24 = 'DVD-RAM'
     25 = 'DVD-ROM'
     26 = 'DVD-Video'
     27 = 'Divx'
     28 = 'Floppy/Diskette'
     29 = 'Hard Disk'
     30 = 'Memory Card'
     31 = 'Hard Copy'
     32 = 'Clik Disk'
     33 = 'CD-RW'
     34 = 'CD-DA'
     35 = 'CD+'
     36 = 'DVD Recordable'
     37 = 'DVD-RW'
     38 = 'DVD-Audio'
     39 = 'DVD-5'
     40 = 'DVD-9'
     41 = 'DVD-10'
     42 = 'DVD-18'
     43 = 'Magneto-Optical Rewriteable'
     44 = 'Magneto-Optical Write Once'
     45 = 'Magneto-Optical Rewriteable (LIMDOW)'
     46 = 'Phase Change Write Once'
     47 = 'Phase Change Rewriteable'
     48 = 'Phase Change Dual Rewriteable'
     49 = 'Ablative Write Once'
     50 = 'Near Field Recording'
     51 = 'MiniQic'
     52 = 'Travan'
     53 = '8mm Metal Particle'
     54 = '8mm Advanced Metal Evaporate'
     55 = 'NCTP'
     56 = 'LTO Ultrium'
     57 = 'LTO Accelis'
     58 = '9 Track Tape'
     59 = '18 Track Tape'
     60 = '36 Track Tape'
     61 = 'Magstar 3590'
     62 = 'Magstar MP'
     63 = 'D2 Tape'
     64 = 'Tape - DST Small'
     65 = 'Tape - DST Medium'
     66 = 'Tape - DST Large'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMedia | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.MediaType  

# translate raw value to friendly text:
$friendlyName = $MediaType_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "MediaType" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "MediaType", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "MediaType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$MediaType = @{
  Name = 'MediaType'
  Expression = {
    # property is an array, so process all values
    $value = $_.MediaType
    
    switch([int]$value)
      {
        0          {'Unknown'}
        1          {'Other'}
        2          {'Tape Cartridge'}
        3          {'QIC Cartridge'}
        4          {'AIT Cartridge'}
        5          {'DTF Cartridge'}
        6          {'DAT Cartridge'}
        7          {'8mm Tape Cartridge'}
        8          {'19mm Tape Cartridge'}
        9          {'DLT Cartridge'}
        10         {'Half-Inch Magnetic Tape Cartridge'}
        11         {'Cartridge Disk'}
        12         {'JAZ Disk'}
        13         {'ZIP Disk'}
        14         {'SyQuest Disk'}
        15         {'Winchester Removable Disk'}
        16         {'CD-ROM'}
        17         {'CD-ROM/XA'}
        18         {'CD-I'}
        19         {'CD Recordable'}
        20         {'WORM'}
        21         {'Magneto-Optical'}
        22         {'DVD'}
        23         {'DVD+RW'}
        24         {'DVD-RAM'}
        25         {'DVD-ROM'}
        26         {'DVD-Video'}
        27         {'Divx'}
        28         {'Floppy/Diskette'}
        29         {'Hard Disk'}
        30         {'Memory Card'}
        31         {'Hard Copy'}
        32         {'Clik Disk'}
        33         {'CD-RW'}
        34         {'CD-DA'}
        35         {'CD+'}
        36         {'DVD Recordable'}
        37         {'DVD-RW'}
        38         {'DVD-Audio'}
        39         {'DVD-5'}
        40         {'DVD-9'}
        41         {'DVD-10'}
        42         {'DVD-18'}
        43         {'Magneto-Optical Rewriteable'}
        44         {'Magneto-Optical Write Once'}
        45         {'Magneto-Optical Rewriteable (LIMDOW)'}
        46         {'Phase Change Write Once'}
        47         {'Phase Change Rewriteable'}
        48         {'Phase Change Dual Rewriteable'}
        49         {'Ablative Write Once'}
        50         {'Near Field Recording'}
        51         {'MiniQic'}
        52         {'Travan'}
        53         {'8mm Metal Particle'}
        54         {'8mm Advanced Metal Evaporate'}
        55         {'NCTP'}
        56         {'LTO Ultrium'}
        57         {'LTO Accelis'}
        58         {'9 Track Tape'}
        59         {'18 Track Tape'}
        60         {'36 Track Tape'}
        61         {'Magstar 3590'}
        62         {'Magstar MP'}
        63         {'D2 Tape'}
        64         {'Tape - DST Small'}
        65         {'Tape - DST Medium'}
        66         {'Tape - DST Large'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_PhysicalMedia | 
  # ...and output properties "Caption" and "MediaType". The latter is defined
  # by the hashtable in $MediaType:
  Select-Object -Property Caption, $MediaType
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_PhysicalMedia", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumMediaType
{
  Unknown                              = 0
  Other                                = 1
  Tape_Cartridge                       = 2
  QIC_Cartridge                        = 3
  AIT_Cartridge                        = 4
  DTF_Cartridge                        = 5
  DAT_Cartridge                        = 6
  _8mm_Tape_Cartridge                  = 7
  _19mm_Tape_Cartridge                 = 8
  DLT_Cartridge                        = 9
  Half_Inch_Magnetic_Tape_Cartridge    = 10
  Cartridge_Disk                       = 11
  JAZ_Disk                             = 12
  ZIP_Disk                             = 13
  SyQuest_Disk                         = 14
  Winchester_Removable_Disk            = 15
  CD_ROM                               = 16
  CD_ROMXA                             = 17
  CD_I                                 = 18
  CD_Recordable                        = 19
  WORM                                 = 20
  Magneto_Optical                      = 21
  DVD                                  = 22
  DVDRW                                = 23
  DVD_RAM                              = 24
  DVD_ROM                              = 25
  DVD_Video                            = 26
  Divx                                 = 27
  FloppyDiskette                       = 28
  Hard_Disk                            = 29
  Memory_Card                          = 30
  Hard_Copy                            = 31
  Clik_Disk                            = 32
  CD_RW                                = 33
  CD_DA                                = 34
  CD                                   = 35
  DVD_Recordable                       = 36
  DVD_RW                               = 37
  DVD_Audio                            = 38
  DVD_5                                = 39
  DVD_9                                = 40
  DVD_10                               = 41
  DVD_18                               = 42
  Magneto_Optical_Rewriteable          = 43
  Magneto_Optical_Write_Once           = 44
  Magneto_Optical_Rewriteable_LIMDOW   = 45
  Phase_Change_Write_Once              = 46
  Phase_Change_Rewriteable             = 47
  Phase_Change_Dual_Rewriteable        = 48
  Ablative_Write_Once                  = 49
  Near_Field_Recording                 = 50
  MiniQic                              = 51
  Travan                               = 52
  _8mm_Metal_Particle                  = 53
  _8mm_Advanced_Metal_Evaporate        = 54
  NCTP                                 = 55
  LTO_Ultrium                          = 56
  LTO_Accelis                          = 57
  _9_Track_Tape                        = 58
  _18_Track_Tape                       = 59
  _36_Track_Tape                       = 60
  Magstar_3590                         = 61
  Magstar_MP                           = 62
  D2_Tape                              = 63
  Tape_DST_Small                       = 64
  Tape_DST_Medium                      = 65
  Tape_DST_Large                       = 66
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_PhysicalMedia | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.MediaType

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **MediaType** 
[EnumMediaType]$rawValue 

# get a comma-separated string:
[EnumMediaType]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumMediaType]
#endregion

Enums must cover all possible values. If MediaType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

Model

STRING

Name by which the physical element is generally known.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Model

Name

STRING

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

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Name

OtherIdentifyingInfo

STRING

Additional data, beyond asset tag information, that can be used to identify a physical element. One example is bar code data associated with an element that also has an asset tag. Note that if only bar code data is available, is unique, and it can be used as an element key, this property is NULL and the bar code data used is the class key in the Tag property.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, OtherIdentifyingInfo

PartNumber

STRING

Part number assigned by the manufacturer of the physical element.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, PartNumber

PoweredOn

BOOLEAN

If TRUE the physical element is powered on.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, PoweredOn

Removable

BOOLEAN

If TRUE, the physical component is designed to be taken in and out of the physical container in which it is normally found, without impairing the function of the overall packaging. A component can still be removable if the power must be “off” to perform the removal. If power can be “on” and the component removed, the element is removable and can be hot-swapped.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Removable

Replaceable

BOOLEAN

If TRUE, this physical media component can be replaced with a physically different one. For example, some computer systems allow the main processor chip to be upgraded to one of a higher clock rating. In this case, the processor is said to be replaceable. All removable components are inherently replaceable.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Replaceable

SerialNumber

STRING

Manufacturer-allocated number used to identify the physical media. The default value is NULL.

Example: WD-WM3493798728

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, SerialNumber

SKU

STRING

Stock keeping unit number for this physical element.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, SKU

Status

STRING

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

$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Status

Tag

KEY PROPERTY STRING MAX 256 CHAR

Uniquely identifies the physical media in the system.

Example: PHYSICALDRIVE0

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag

Version

STRING

Version of the physical element.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, Version

WriteProtectOn

BOOLEAN

If TRUE, the media is currently write protected by some kind of physical mechanism, such as a protect tab on a floppy disk.

Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property Tag, WriteProtectOn

Examples

List all instances of Win32_PhysicalMedia
Get-CimInstance -ClassName Win32_PhysicalMedia

Learn more about Get-CimInstance and the deprecated Get-WmiObject.

View all properties
Get-CimInstance -ClassName Win32_PhysicalMedia -Property *
View key properties only
Get-CimInstance -ClassName Win32_PhysicalMedia -KeyOnly

Selecting Properties

To select only some properties, pipe the results to Select-Object -Property a,b,c with a comma-separated list of the properties you require. Wildcards are permitted.

Get-CimInstance always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object if you want to limit the visible properties, i.e. for reporting.

Selecting Properties

The code below lists all available properties. Remove the ones you do not need:

$properties = 'Capacity',
              'Caption',
              'CleanerMedia',
              'CreationClassName',
              'Description',
              'HotSwappable',
              'InstallDate',
              'Manufacturer',
              'MediaDescription',
              'MediaType',
              'Model',
              'Name',
              'OtherIdentifyingInfo',
              'PartNumber',
              'PoweredOn',
              'Removable',
              'Replaceable',
              'SerialNumber',
              'SKU',
              'Status',
              'Tag',
              'Version',
              'WriteProtectOn'
Get-CimInstance -ClassName Win32_PhysicalMedia | Select-Object -Property $properties
Limiting Network Bandwidth

If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:

Get-CimInstance -Class Win32_PhysicalMedia -Property $property | 
Select-Object -Property $property

Selecting Instances

To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).

The parameter -Filter runs a simple query.

Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_PhysicalMedia -Filter 'Caption LIKE "a%"' 
Using a WQL Query

The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:

Get-CimInstance -Query "SELECT Version, Name, Removable, PartNumber FROM Win32_PhysicalMedia WHERE Caption LIKE 'a%'"

Any property you did not specify is still present but empty. You might need to use Select-Object to remove all unwanted properties:

Get-CimInstance -Query "SELECT Version, Name, Removable, PartNumber FROM Win32_PhysicalMedia WHERE Caption LIKE 'a%'" | Select-Object -Property Version, Name, Removable, PartNumber

Accessing Remote Computers

To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.

Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_PhysicalMedia -ComputerName $list 
$result
Authenticating as Different User

Use a CIMSession object to authenticate with a new identity:

# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred

$result = Get-CimInstance Win32_PhysicalMedia -CimSession $session

# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session

$result

Learn more about accessing remote computers.

Requirements

To use Win32_PhysicalMedia, 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

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

Namespace

Win32_PhysicalMedia lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

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

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