root\wmi–Monitor information

Continuing our intermittent browse through the root\wmi namespace we find a set of classes that seem to be linked to monitors

Get-WmiObject -Namespace root\wmi -List WmiMonitor*

WmiMonitorBrightnessEvent
WmiMonitorConnectionParams
WmiMonitorRawEEdidV1Block
WmiMonitorListedFrequencyRanges
WmiMonitorDigitalVideoInputParams
WmiMonitorAnalogVideoInputParams
WmiMonitorID
WmiMonitorBrightnessMethods
WmiMonitorBasicDisplayParams
WmiMonitorColorCharacteristics
WmiMonitorDescriptorMethods
WmiMonitorListedSupportedSourceM…
WmiMonitorBrightness
WmiMonitorColorXYZinCIE
WmiMonitorSupportedDisplayFeatures

 

WmiMonitorBasicDisplayParams   seems like a good place to start

Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams

produces

Active                        : True
DisplayTransferCharacteristic : 120
InstanceName                  : DISPLAY\LGD6301\5&21e3487a&0&UID33554704_0
MaxHorizontalImageSize        : 34
MaxVerticalImageSize          : 19
SupportedDisplayFeatures      : System.Management.ManagementBaseObject
VideoInputType                : 1

 

The supporteddisplayfeatures we need to dig into a bit

$monitor = Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams
$monitor.SupportedDisplayFeatures

ActiveOffSupported     : False
DisplayType            : 1
GTFSupported           : False
HasPreferredTimingMode : True
sRGBSupported          : False
StandbySupported       : False
SuspendSupported       : False

 

For interest sake the screen resolution of this monitor is 1366 x 768

We can calculate the approximate monitor size – which is the diagonal size – the max horizontal and vertical image sizes are truncated to the nearest centimeter. I think in inches so I want to convert

function get-monitorsize {
Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams |
select  @{N=”Computer”; E={$_.__SERVER}},
InstanceName,
@{N=”Horizonal”; E={[System.Math]::Round(($_.MaxHorizontalImageSize/2.54), 2)}},
@{N=”Vertical”; E={[System.Math]::Round(($_.MaxVerticalImageSize/2.54), 2)}},
@{N=”Size”;
E={[System.Math]::Round(([System.Math]::Sqrt([System.Math]::Pow($_.MaxHorizontalImageSize, 2) `
+ [System.Math]::Pow($_.MaxVerticalImageSize, 2))/2.54),2)}}
}

A little bit of pythagoras theorem and division by 2.54 gives me results I can understand.

Advertisements
This entry was posted in PowerShell and WMI. Bookmark the permalink.

One Response to root\wmi–Monitor information

  1. Pingback: Get Monitor Size programmatically | theezitguy

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s