Reputation: 21
The machines I am scanning have 2-3 monitors.
This command does almost everything that I need.
Get-CimInstance WmiMonitorID -Namespace root\wmi
However my report needs to include resolution and refresh rate of the monitors.
I had actually figured this out before but can't remember how I did it.
I am specifically looking these properties OF EACH MONITOR:
I believe I used:
Get-WMiObject
or
get-ciminstance
and then somehow used
CIM_MonitorResolution
(https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/cim-monitorresolution)
I also tried: For ciminstace I used:
get-ciminstance -classname CIM_MonitorResolution
get-ciminstance -classname CIM_MonitorResolution -Namespace "root\cimv2"
These never errored out but they also don't display anything. This got me close:
Get-CimInstance -Namespace "root\cimv2" -ClassName "CIM_VideoControllerResolution"
but it displays every single resolution and refresh that your monitors can use but it doesn't say what monitor.
Does anyone know how I would get those properties for the monitors using powershell without any 3rd party utilities like from Nirsoft.
I am specifically looking these properties OF EACH MONITOR:
HorizontalResolution;
VerticalResolution;
MaxRefreshRate;
RefreshRate;
Upvotes: 2
Views: 135
Reputation: 51
My module DisplayConfig
can get the resolution and refresh rate info with Get-DisplayInfo
. I don't currently have a way to get the max refresh rate, but you can get it in a hacky way through tab completion (TabExpansion2 'Set-DisplayRefreshRate -DisplayId 1 -RefreshRate:').CompletionMatches.CompletionText | sort {[double]$_} -Descending | select -First 1
Here's a full example:
Get-DisplayInfo | Where-Object -Property Active -EQ $true | ForEach-Object -Process {
[pscustomobject]@{
DisplayId = $_.DisplayId
DisplayName = $_.DisplayName
Width = $_.Mode.Width
Height = $_.Mode.Height
RefreshRate = $_.Mode.RefreshRate
MaxRefreshRate = (TabExpansion2 "Set-DisplayRefreshRate -DisplayId $($_.DisplayId) -RefreshRate:").CompletionMatches.CompletionText | sort {[double]$_} -Descending | select -First 1
}
}
It should be noted that this doesn't take the current resolution into account which can lead to misleading results. For example your display may support 120 Hz but only at 1080p without HDR enabled so if you are at 4K you won't actually be able to use the listed refresh rate.
Upvotes: 2