PoshCode Archive  Artifact [7712e644cf]

Artifact 7712e644cf73b37862b1e150587170bfa5c086664b1b1e96ebb8c7d9bb36f826:

  • File Get-Monitor-Size.ps1 — part of check-in [a213a38bcb] at 2018-06-10 13:44:37 on branch trunk — This script queries WMI to find basic monitor size information. It then performs some math on these attributes to come up with the size of all monitors attached to a local or remote device. (user: Adam Bertram size: 1243)

# encoding: ascii
# api: powershell
# title: Get Monitor Size
# description: This script queries WMI to find basic monitor size information.  It then performs some math on these attributes to come up with the size of all monitors attached to a local or remote device.
# version: 2.54
# author: Adam Bertram
# license: CC0
# x-poshcode-id: 4688
# x-archived: 2015-04-15T22:38:05
# x-published: 2015-12-11T03:59:00
#
#
param($ComputerName = 'COMPUTERNAME')

$output = [PSCustomObject]@{ComputerName = $ComputerName;MonitorSizes=''}

$oWmi = Get-WmiObject -Namespace 'root\wmi' -ComputerName $ComputerName -Query "SELECT MaxHorizontalImageSize,MaxVerticalImageSize FROM WmiMonitorBasicDisplayParams";
$sizes = @();
if ($oWmi.Count -gt 1) {
	foreach ($i in $oWmi) {
		$x = [System.Math]::Pow($i.MaxHorizontalImageSize/2.54,2)
		$y = [System.Math]::Pow($i.MaxVerticalImageSize/2.54,2)
        $sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
	}##endforeach
} else {
	$x = [System.Math]::Pow($oWmi.MaxHorizontalImageSize/2.54,2)
	$y = [System.Math]::Pow($oWmi.MaxVerticalImageSize/2.54,2)
	$sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
}##endif

$output.MonitorSizes = $sizes

$output