Get Screen resolution using WMI/powershell in Windows 7
For the record, the PowerShell code is:
Get-WmiObject -Class Win32_DesktopMonitor | Select-Object ScreenWidth,ScreenHeight
I get the same values in Landscape or in Portrait mode.
UPDATE:
In a multi monitor environment you can get the info for all monitors with:
PS> Add-Type -AssemblyName System.Windows.FormsPS> [System.Windows.Forms.Screen]::AllScreensBitsPerPixel : 32Bounds : {X=0,Y=0,Width=1280,Height=800}DeviceName : \\.\DISPLAY1Primary : TrueWorkingArea : {X=0,Y=0,Width=1280,Height=770}BitsPerPixel : 32Bounds : {X=1280,Y=0,Width=1920,Height=1200}DeviceName : \\.\DISPLAY2Primary : FalseWorkingArea : {X=1280,Y=0,Width=1920,Height=1170}
You can grab this from the Win32_VideoController
WMI class. The VideoModeDescription
property includes the screen resolution and the color depth.
(Get-WmiObject -Class Win32_VideoController).VideoModeDescription;
Result
1600 x 900 x 4294967296 colors
Same as the other answers, however for the plain cmd:
wmic path Win32_VideoController get VideoModeDescription