I type the command in Get Screen resolution using WMI/powershell in Windows 7, but I get empty result (I'm on Surface Pro 2017, single screen)?
Asked
Active
Viewed 1,819 times
2
-
What do you get for this? `Get-WmiObject -Class Win32_Desktopmonitor` – Sid Jul 21 '18 at 07:57
-
@RohinSidharth empty also DeviceID : DesktopMonitor1 DisplayType : MonitorManufacturer : Surface Name : Surface Display ScreenHeight : ScreenWidth : – user310291 Jul 21 '18 at 08:39
-
@ansgarwiechers why is my question voted to close just because nobody knows the answer about wmi ? I know there is alternative with winform but that's not my question, my question is about wmi. – user310291 Jul 21 '18 at 14:19
-
1@user310291 You need to ask that the person who close-voted this question. – Ansgar Wiechers Jul 21 '18 at 14:50
-
@AnsgarWiechers is there a way to know who downvoted though ? – user310291 Jul 23 '18 at 00:47
-
No. This behavior is by design. – Ansgar Wiechers Jul 23 '18 at 08:14
1 Answers
4
I don't have a Surface, but does this work?
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
[pscustomobject]@{
DeviceName = $screen.DeviceName.Split('\\')[-1]
Width = $screen.Bounds.Width
Height = $screen.Bounds.Height
BitsPerPixel = $screen.BitsPerPixel
}
EDIT
Using CIM_VideoController
$screen = Get-CimInstance -ClassName CIM_VideoController
[pscustomobject]@{
DeviceName = $screen.Caption
Width = $screen.CurrentHorizontalResolution
Height = $screen.CurrentVerticalResolution
BitsPerPixel = $screen.CurrentBitsPerPixel
}

Theo
- 57,719
- 8
- 24
- 41
-
-
Apparently, starting with Windows Vista, hardware that is not compatible with Longhorn Display Driver Model (LDDM) returns inaccurate property values for instances of this class. Instead, you can use the `CIM_VideoController` object and get properties `CurrentHorizontalResolution`, `CurrentVerticalResolution` and `CurrentBitsPerPixel` from that (and more). Usage `Get-CimInstance -ClassName CIM_VideoController` – Theo Jul 21 '18 at 15:19
-
I'm on a Surface Pro 3 (Windows 10 Build 17713) and `Get-WmiObject -Class Win32_Desktopmonitor` correctly returns `ScreenWidth : 2160 ScreenHeight : 1440` – Jacob Jul 21 '18 at 17:38
-
-
@Theo CIM_VideoController returns something : 2736 1824 which are maximum resolution I guess whereas my current resolution is set lower. But since that's also an interesting info, I'll check as good answer :) – user310291 Jul 23 '18 at 00:46