Reputation: 38228
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)?
Upvotes: 2
Views: 2106
Reputation: 61178
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
}
Upvotes: 4