Here is the code which displays information about the monitor connected to my computer which works fine.
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)} },
@{N="Ratio";E={[System.Math]::Round(($_.MaxHorizontalImageSize)/($_.MaxVerticalImageSize),2)} }
What I need is to separate the output as Monitor 1, Monitor 2 and Monitor 3 based on the number of monitors connected. The current code will output the following:
Computer : HOME-HP
InstanceName : DISPLAY\HWP3183\4&1badc1af&0&UID200195_0
Horizonal : 18.9
Vertical : 10.63
Size : 21.68
Ratio : 1.78
Computer : HOME-HP
InstanceName : DISPLAY\HPN3394\4&1badc1af&0&UID224795_0
Horizonal : 20.87
Vertical : 11.81
Size : 23.98
Ratio : 1.77
But I want is below
Computer : HOME-HP
Monitor 1 InstanceName : DISPLAY\HWP3183\4&1badc1af&0&UID200195_0
Monitor 1 Horizonal : 18.9
Monitor 1 Vertical : 10.63
Monitor 1 Size : 21.68
Monitor 1 Ratio : 1.78
Computer : HOME-HP
Monitor 2 InstanceName : DISPLAY\HPN3394\4&1badc1af&0&UID224795_0
Monitor 2 Horizonal : 20.87
Monitor 2 Vertical : 11.81
Monitor 2 Size : 23.98
Monitor 2 Ratio : 1.77