PowerShell 获取接在电脑上显示器的序列号,支持多个

$Monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
function Decode {
    If ($args[0] -is [System.Array]) {
        [System.Text.Encoding]::ASCII.GetString($args[0])
   }
    Else {
        continue
    }
}
$result = ForEach ($Monitor in $Monitors) {  
    $Manufacturer = Decode $Monitor.ManufacturerName -notmatch 0
    $Name = Decode $Monitor.UserFriendlyName -notmatch 0
    $Serial = Decode $Monitor.SerialNumberID -notmatch 0

    $Serial
}
$result -join ","

  

posted @ 2023-07-27 14:45  人生若只ru初恋  阅读(649)  评论(0)    收藏  举报