Number of Displays
It would be nice to see the number of displays that are connected to a agent pc under "Hardware"
-
itsupport itsupport
commented
function Convert-MonitorString {
param (
[UInt16[]]$Value
)if ($null -eq $Value) {
return ""
}return (($Value |
Where-Object { $_ -ne 0 } |
ForEach-Object { [char]$_ }) -join "").Trim()
}$BasicInfo = Get-CimInstance -Namespace root\wmi `
-ClassName WmiMonitorBasicDisplayParams |
Where-Object { $_.Active -eq $true }$MonitorIDs = Get-CimInstance -Namespace root\wmi `
-ClassName WmiMonitorIDWrite-Output "Number of monitors: $(@($BasicInfo).Count)"
Write-Output ""$Number = 1
foreach ($Monitor in $BasicInfo) {
$ID = $MonitorIDs |
Where-Object { $_.InstanceName -eq $Monitor.InstanceName } |
Select-Object -First 1$Manufacturer = Convert-MonitorString $ID.ManufacturerName
$Model = Convert-MonitorString $ID.UserFriendlyName
$SerialNumber = Convert-MonitorString $ID.SerialNumberID$Width = $Monitor.MaxHorizontalImageSize
$Height = $Monitor.MaxVerticalImageSizeif (($Width -gt 0) -and ($Height -gt 0)) {
$Diagonal = [math]::Round(
[math]::Sqrt(($Width * $Width) + ($Height * $Height)) / 2.54,
1
)$PhysicalSize = "$Width x $Height cm"
$DiagonalText = "$Diagonal inches"
}
else {
$PhysicalSize = "Unknown"
$DiagonalText = "Unknown"
}if ($Monitor.VideoInputType -eq 1) {
$InputType = "Digital"
}
else {
$InputType = "Analog"
}Write-Output "Monitor number: $Number"
Write-Output "Manufacturer: $Manufacturer"
Write-Output "Model: $Model"
Write-Output "Serial number: $SerialNumber"
Write-Output "Physical size: $PhysicalSize"
Write-Output "Diagonal: $DiagonalText"
Write-Output "Input type: $InputType"
Write-Output "Active: $($Monitor.Active)"
Write-Output "Instance name: $($Monitor.InstanceName)"
Write-Output "----------------------------------------"$Number++
} -
itsupport itsupport
commented
"Number of monitors: $((Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams |
Where-Object { $_.Active -eq $true }).Count)" -
Mehran Ajaz
commented
Is there an update on this?