用 PowerShell 查看屏幕分辨率

通过 .NET Screen 类读取每台显示器的分辨率和布局,远程桌面场景特别有用。

Windows显示器分辨率PowerShell低风险
先用 Add-Type 加载 System.Windows.Forms,再读取 [System.Windows.Forms.Screen]::AllScreens,查看每台显示器的 DeviceName、Bounds 和 Primary 标志。

01命令

命令
$ Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens | Format-Table DeviceName, @{n='Resolution';e={$_.Bounds.Width.ToString()+'x'+$_.Bounds.Height}}, Primary

02作用说明

在远程桌面或脚本里,这条命令不用打开显示设置就能回答“那台显示器现在到底是多少分辨率”,还能看清多显示器布局:每个 Screen 对象带有 Bounds(位置和尺寸)、WorkingArea(去掉任务栏的区域)和 Primary(是否主屏)标志。PowerShell 没有内置的分辨率查询 cmdlet,所以调用 .NET 类是标准做法。返回值是 Windows 报告的原始像素几何,不应用 DPI 缩放系数,150% 缩放的 1920x1080 屏仍然显示 1920x1080。想用脚本改分辨率需要调用 ChangeDisplaySettings API——这条命令只负责读取。

03风险

风险低风险

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Screen class (System.Windows.Forms)
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Documents the Screen class with AllScreens, PrimaryScreen, Bounds, and DeviceName members used to read display geometry.

最后验证: 2026-09-18 · 分类: 系统与设置

06相关方案