The Powershell code described in this article will help you to get screen resolution details of your desktops It uses System.Drawing and System.Windows.Forms namespaces. The Screen class in System.Windows.Forms provides the data we need — that is screen resolution details. This code will also tell you which one is your primary monitor and it’s resolution details.
Code:
function Get-ScreenResolution { [void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [Reflection.Assembly]::LoadWithPartialName("System.Drawing") $Screens = [system.windows.forms.screen]::AllScreens foreach ($Screen in $Screens) { $DeviceName = $Screen.DeviceName $Width = $Screen.Bounds.Width $Height = $Screen.Bounds.Height $IsPrimary = $Screen.Primary $OutputObj = New-Object -TypeName PSobject $OutputObj | Add-Member -MemberType NoteProperty -Name DeviceName -Value $DeviceName $OutputObj | Add-Member -MemberType NoteProperty -Name Width -Value $Width $OutputObj | Add-Member -MemberType NoteProperty -Name Height -Value $Height $OutputObj | Add-Member -MemberType NoteProperty -Name IsPrimaryMonitor -Value $IsPrimary $OutputObj } }
Output:
Hope this helps…
Comments on this entry are closed.
Can we also find serial number for a desktop monitor. Please let me know if we can do this using powershell.
Try this post. http://www.hofferle.com/retrieve-monitor-serial-numbers-with-powershell/
After copying the code, change name space from “rootwmi” to “root\wmi”. Thats typo in the script
Great work! I have tried your other script Get-IPDetails.ps1 run it against a CSV file with all my computers, it worked like a charm:
Get-Content “Z:\Resources\Scripts\CHI-ComputerNames.csv” | .\Get-IPDetails.PS1 | ft -AutoSize
I tried doing the same with this one to get the same result but I have no luck, I’m using:
Get-Content “Z:\Resources\Scripts\CHI-ComputerNames.csv” | .\Get-ScreenResolution.ps1 | ft -AutoSize
I get nothing, no errors, no data info.. can you advise?
Congratulation for this function.
This is actually a really good work … Simple … Efficient and the return is just as I expected it !
Glad to know that it helped.