# 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