昨天从mklement0获得了严重的帮助
但是当我继续研究脚本时,我遇到了我研究和研究的另一个问题,持续了两天的时间。
Add-Type -AssemblyName System.Windows.Forms
$Monitors = [System.Windows.Forms.Screen]::AllScreens
foreach ($Monitor in $Monitors)
{
$connections = get-ciminstance -namespace root/wmi -classname WmiMonitorConnectionParams
$videooutput = $connections.VideoOutputTechnology
$DeviceName = (($Monitor.DeviceName).replace("\", "")).replace(".", "")
$Width = $Monitor.bounds.Width
$Height = $Monitor.bounds.Height
Foreach ($type in $videooutput){
switch ($videooutput) {
10 { $type = "DP"; break}
4 { $type = "DVI"; break}
5 { $type = "HDMI"; break}
0 { $type = "VGA"; break}
default { "unknown"}
}
}
Write-Host "$DeviceName - $Width x $height - $Type"
}
我得到的答案是:
DISPLAY1 - 1920 x 1080 - DVI
DISPLAY2 - 1920 x 1080 - DVI
答案应该是:
DISPLAY1 - 1920 x 1080 - DVI
DISPLAY2 - 1920 x 1080 - DP