How to get the screen resolution in Windows 10 using PowerShell

Get Screen Resolution of remote computers

Administrators sometimes have to document certain properties of the computers in their network. The most common one is the screen resolution. Doing so on a collection of remote computers only adds to the complication. However, with the help of the below PowerShell script, one can get the screen resolution of a remote machine. 

How to get the screen resolution in Windows 10 using PowerShell

The Get-DisplayResolution WMI cmdlet shows the display resolution for Windows 10 computers. Use the following PowerShell script to get the current screen resolution. Provide the computer name as the parameter and run the script. The resolution of the screen will be displayed. 

Script
<#
.SYNOPSIS
This script can be used to display the Screen Resolution of a Remote machine
.DESCRIPTION
This script can be used to display Screen Resolution information of a Remote machine.
.EXAMPLE
C:\PS> C:\Script\Resolution.ps1
Displays Screen Resolution of a Local machine.
.EXAMPLE
C:\PS> C:\Script\Resolution.ps1 admp-dc1 admp\administrator
Displays Screen Resolution information of a Remote machine.
#>

param( [string]$strComputer=”.”,[string]$Cred)
if($Cred -eq “”)
{
#To display screen resolution of a local machine.

$colItems = get-wmiobject -class “Win32_DisplayConfiguration” -namespace “root\CIMV2” -computername $strComputer
}
else
{
#To display screen resolution of a Remote machine.

$colItems = get-wmiobject -class “Win32_DisplayConfiguration” -namespace “root\CIMV2” -computername $strComputer -Credential $cred
}
if($colItems)
{
foreach ($objItem in $colItems) {
write-host “Device Name :” $objItem.DeviceName
write-host “Pels Width :” $objItem.PelsWidth
write-host “Pels Height :” $objItem.PelsHeight
write-host “Bits Per Pel :” $objItem.BitsPerPel
write-host “Display Frequency :” $objItem.DisplayFrequency
}
}