CIM_VideoControllerResolution

CIM_VideoControllerResolution represents a video mode that a video controller can support. Video modes are defined by the possible horizontal and vertical resolutions, refresh rate, scan mode, and ...

Methods

CIM_VideoControllerResolution has no methods.

Properties

CIM_VideoControllerResolution returns 9 properties:

'Caption','Description','HorizontalResolution','MaxRefreshRate','MinRefreshRate',
'NumberOfColors','RefreshRate','ScanMode','VerticalResolution'

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

Caption

STRING MAX 64 CHAR

Short textual description of the current object.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, Caption

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, Caption | Foreach-Object {

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

Description

STRING

Textual description of the current object.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, Description

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

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

HorizontalResolution

UINT32 “PIXELS”

Horizontal resolution, in pixels.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, HorizontalResolution

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, HorizontalResolution | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.HorizontalResolution
  "${ScanMode}: HorizontalResolution = $value pixels"
}

MaxRefreshRate

UINT32 “HERTZ”

Maximum refresh rate when a range of rates is supported at the specified resolutions, in hertz.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, MaxRefreshRate

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, MaxRefreshRate | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.MaxRefreshRate
  "${ScanMode}: MaxRefreshRate = $value hertz"
}

MinRefreshRate

UINT32 “HERTZ”

Minimum refresh rate when a range of rates is supported at the specified resolutions, in hertz.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, MinRefreshRate

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, MinRefreshRate | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.MinRefreshRate
  "${ScanMode}: MinRefreshRate = $value hertz"
}

NumberOfColors

UINT64

Number of colors supported at the current resolution.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, NumberOfColors

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, NumberOfColors | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.NumberOfColors
  "${ScanMode}: NumberOfColors = $value"
}

RefreshRate

UINT32 “HERTZ”

Refresh rate, in hertz. If a range of rates is supported, use the MinRefreshRate and MaxRefreshRate properties, and set this property to 0.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, RefreshRate

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, RefreshRate | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.RefreshRate
  "${ScanMode}: RefreshRate = $value hertz"
}

ScanMode

KEY PROPERTY STRING MAX 256 CHAR

Scan mode at which the controller operates.

ScanMode 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 ScanMode -TypeName "Microsoft.Management.Infrastructure.CimInstance#root/cimv2/cim_videocontrollerresolution" -MemberType ScriptProperty  -Value {
  Enum EnumScanMode
  {
    Other                      = 1
    Unknown                    = 2
    Not_Supported              = 3
    Non_Interlaced_Operation   = 4
    Interlaced_Operation       = 5
  }

  [EnumScanMode]($this.PSBase.CimInstanceProperties['ScanMode'].Value)
} -Force

Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, ScanMode
Use Select-Object

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

$ScanMode = @{
  Name = 'ScanModeText'
  Expression = {
    $value = $_.ScanMode
    
    switch([int]$value)
      {
        1          {'Other'}
        2          {'Unknown'}
        3          {'Not Supported'}
        4          {'Non-Interlaced Operation'}
        5          {'Interlaced Operation'}
        default    {"$value"}
      }
      
  }  
}

Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, ScanMode, $ScanMode
Use a PowerShell Hashtable

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

$ScanMode_map = @{
      1 = 'Other'
      2 = 'Unknown'
      3 = 'Not Supported'
      4 = 'Non-Interlaced Operation'
      5 = 'Interlaced Operation'
}
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 EnumScanMode
{
  Other                      = 1
  Unknown                    = 2
  Not_Supported              = 3
  Non_Interlaced_Operation   = 4
  Interlaced_Operation       = 5
}

VerticalResolution

UINT32 “PIXELS”

Controller’s vertical resolution, in pixels.

# returning class instances:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, VerticalResolution

# reading property value:
Get-CimInstance -ClassName CIM_VideoControllerResolution | Select-Object -Property ScanMode, VerticalResolution | Foreach-Object {

  $ScanMode = $_.ScanMode
  $value = $_.VerticalResolution
  "${ScanMode}: VerticalResolution = $value pixels"
}

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_VideoControllerResolution.cdxml
$folder = "c:\wmi\CIM_VideoControllerResolution"
$cdxmlPath = Join-Path -Path $folder -ChildPath "CIM_VideoControllerResolution.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_videocontrollerresolution#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_VideoControllerResolution" 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>WmiVideoControllerResolution</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="Description">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="HorizontalResolution">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="MaxRefreshRate">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="MinRefreshRate">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="NumberOfColors">
              <Type PSType="system.uint64" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="RefreshRate">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="ScanMode">
              <Type PSType="system.string" />
              <RegularQuery AllowGlobbing="true">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
            <Property PropertyName="VerticalResolution">
              <Type PSType="system.uint32" />
              <RegularQuery AllowGlobbing="false">
                <CmdletParameterMetadata IsMandatory="false" />
              </RegularQuery>
            </Property>
          </QueryableProperties>
        </GetCmdletParameters>
      </GetCmdlet>
      <!--defining additional cmdlets that modifies instance properties-->
    </InstanceCmdlets>
  </Class>
</PowerShellMetadata>
'@ | Set-Content -LiteralPath $cdxmlPath -Encoding UTF8

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

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

Requirements

To use CIM_VideoControllerResolution, 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_VideoControllerResolution was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

CIM_VideoControllerResolution 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_VideoControllerResolution 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