user310291
user310291

Reputation: 38228

Why do I get empty for screen resolution in PowerShell on Windows 10?

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)?

enter image description here

Upvotes: 2

Views: 2106

Answers (1)

Theo
Theo

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

Related Questions