PowerShell」タグアーカイブ

PowerShellからマルチスクリーンの解像度を取得

Windows の PowerShellから、マルチスクリーンの解像度を取得する方法。

PS> Add-Type -AssemblyName System.Windows.Forms
PS> [System.Windows.Forms.Screen]::AllScreens

BitsPerPixel : 32
Bounds       : {X=0,Y=0,Width=2560,Height=1440}
DeviceName   : \\.\DISPLAY1
Primary      : True
WorkingArea  : {X=0,Y=0,Width=2560,Height=1400}

BitsPerPixel : 32
Bounds       : {X=2560,Y=0,Width=1344,Height=840}
DeviceName   : \\.\DISPLAY2
Primary      : False
WorkingArea  : {X=2560,Y=0,Width=1344,Height=800}

Add-Type -AssemblyName System.Windows.Formsで、PowerShell以外のAPIにアクセスできるようにして、WPFのライブラリを叩けるようにするのが肝。

Via! https://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7