【问题标题】:Why is ManufacturerName and UserFriendlyName incomplete?为什么 ManufacturerName 和 UserFriendlyName 不完整?
【发布时间】:2019-06-20 20:51:53
【问题描述】:

运行此脚本:

$FormatEnumerationLimit =-1
Get-WmiObject WmiMonitorID -Namespace root\wmi
$Monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
$LogFile = "C:\Users\monkeygead\Desktop\monitors.txt"

"Manufacturer,Name,Serial"

ForEach ($Monitor in $Monitors)
{
    $Manufacturer = ($Monitor.ManufacturerName -notmatch 0 | ForEach{[char]$_}) -join ""
    $Name = ($Monitor.UserFriendlyName -notmatch 0 | ForEach{[char]$_}) -join ""
    $Serial = ($Monitor.SerialNumberID -notmatch 0 | ForEach{[char]$_}) -join ""

    "$Manufacturer,$Name,$Serial"
}

它正在输出:

戴尔,戴尔 U415,CV9N64604TL
戴尔,戴尔U415,​​CV9N81S1C6S

为什么制造商报告为 DEL 而不是 DELL,型号报告为 DELL U415 而不是 DELL U2415?

【问题讨论】:

  • 监视器 ROM 中的存储空间很小。非常非常非常小。 [grin] 所以你只会找到他们有空间的东西 - 优先考虑 SN。

标签: powershell get-wmiobject


【解决方案1】:

使用你的代码,我也得到部分残缺的数据,

SAM,SycMastr,H9XQ900000
SAM,SycMastr,H1AK500000

我的this answer不是这样

$FormatEnumerationLimit =-1
Get-WmiObject WmiMonitorID -Namespace root\wmi
$Monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
$LogFile = Join-Path ([Environment]::GetFolderPath('Desktop')) "monitors.csv"

$Data = ForEach ($Monitor in $Monitors){
   [PSCustomObject]@{
           Manufacturer = (-join [char[]] $Monitor.ManufacturerName)
           Name         = (-join [char[]] $Monitor.UserFriendlyName)
           Serial       = (-join [char[]] $Monitor.SerialNumberID)
    }
}

$Data
# $Data | Out-Gridview
# $Data | Export-Csv $LogFile -NoTypeInformation

Manufacturer     Name          Serial
------------     ----          ------
SAM              SyncMaster    H9XQ000000
SAM              SyncMaster    H1AK500000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 1970-01-01
    • 2020-03-04
    • 2021-10-01
    • 1970-01-01
    • 2022-01-15
    • 2014-12-09
    相关资源
    最近更新 更多