none
How to get serial numbers of monitors from remote computers

    Question

  • Hi everyone,

    I am new to scripting and just started to use PowerShell.  I tried to get get serial numbers of monitors from remote computers and tried the following line on my own PC but get a message said, "Get-Wmiobject : Invalid Class".

    The code that I used is

    $trComputer = "."
    $collection = get-wmiobject -class "WinMonitorID" -namespace "root\WMI -computername $trComputer

    I found this class from the WMI Reference but I cannot not see it in the WMI Object Browser.

    Kind Regards
    Han
    Wednesday, June 17, 2009 4:04 AM

Answers

All replies

  • You must have got the class name wrong. Where in the reference did you find WinMonitorID?
    You also miss the closing quotes around root\WMI. I suspect root\WMI is wrong too. Most hardware related classes are found in the root\cimv2 namespace.
    Wednesday, June 17, 2009 7:25 AM
  • It is actually WmiMonitorID and I beleive it is available on Vista and above (PowerShell v2 solution):

    PS > $monitor = gwmi WmiMonitorID -Namespace root\wmi
    PS > ($monitor.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join ""
    SAM

    PS > ($monitor.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join ""
    SyncMaster

    PS > ($monitor.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join ""
    HVCP901666



    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    Wednesday, June 17, 2009 1:24 PM
    Moderator
  • Nice, i didn't know about that one. 
    Any experiences about it? How well does it work? I mean how many monitors supply this information?
    Wednesday, June 17, 2009 1:28 PM
  • Many thanks for all the messages.  I will try it out and let you know.
    Thursday, June 18, 2009 1:11 AM
  • Hi,

    I am sorry for not getting back to this for a while.

    I did found out that this class is not available on XP and I have to work with XP for the moment.  I try this on Windows 7 and it works.  Many thanks
    Monday, August 31, 2009 4:20 AM
  • There is a way to get Monitor Serial Numbers in XP (it's not pretty, but it works...it involves using remote registry, and parsing a binary registry value)  I just posted a script that will do this on my blog:

    http://www.hackyeah.com/2010/08/powershell-pc-info-script-wmi/

    Tuesday, August 10, 2010 5:05 PM
  • Many thanks Trenton.ivey

    I actually found a VB script that was written by Michael Baird and had rewritten it in Powershell that does that same job as the Monitor Serial Numbers (registry) part in your script.

    I like your script and trying to learn how to use the data objects.

     

    Kind regards

    Han


    Wednesday, August 11, 2010 2:20 AM
  • Nice!

    For multiple monitors:

    gwmi WmiMonitorID -Namespace root\wmi | ForEach-Object {($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join ""; ($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join ""}
    
    
    

    DELL 007W
    H73074QE5L
    DELL 1905
    W86905BG1EBA

    Karl


    http://unlockpowershell.wordpress.com
    -join("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    Wednesday, August 11, 2010 2:07 PM
  • Many thanks for this.

    For getting monitor serial numbers, it is much easier on Windows Vista and later than on XP.

    Thursday, August 12, 2010 12:36 AM
  • Hey there,
    Recently i had a task related to "Dell monitors" and getting the Serial Number,..

    i used all that i know, i asked DELL:
    http://en.community.dell.com/support-forums/peripherals/f/3529/p/19658151/20839514#20839514

    the problem is: Dell monitors have a serial that is incomplete in windows:

    1. the written serial on Device:
    CN-0V6WMN-72872-14L-0RYI
    2. the serial retrived from registry/wmi/cim,...:
    V6WMN14L0RYI 

    The "72872" is related to:  Factory ID 

    CN-00FFXD-74261-3AB-1KFS
    CN = China
    0FFXD = Dell part number
    74261 = Factory ID (confidential)
    3AB = Date code (October 11, 2013)
    1KFS = Manufacturer code (confidential)

    Is there somone who had the same problem or know where i ken get that info?

    Monday, November 02, 2015 11:19 AM
  • Hi Calin,

    I was wondering if you ever found a solution for the above issue? I've noticed the same issue.

    Kind regards,

    Thomas

    Tuesday, February 16, 2016 8:09 AM
  • Hi Thomas,

    Yes, there is a solution to this problem. It is simple, the check is

    $_.UserFriendlyName -notmatch 0

    This is always true as long as the decimal number contains a 0. The intention of this check is to remove the leading and trailing Zeros. This has to be changed to

    $_.UserFriendlyName -ne 0

    It worked for me. And now I use this one.

    $Monitor = gwmi wmimonitorid -namespace root\wmi -ComputerName workstation
    
    $Monitor | %{
        $psObject = New-Object PSObject
        $psObject | Add-Member NoteProperty SerialNumber ""
        $psObject | Add-Member NoteProperty Name ""
        $psObject | Add-Member NoteProperty WorkstationName ""
        $psObject.SerialNumber = ($_.SerialNumberID -ne 0 | %{[char]$_}) -join ""
        $psObject.Name = ($_.UserFriendlyName -ne 0 | %{[char]$_}) -join ""
        $psObject.WorkstationName = $_.PSComputerName
        $psObject
    } | Out-GridView

    Best regards

    Markus


    • Edited by Laîss Tuesday, January 24, 2017 4:47 PM Code updated, as there was an error
    Tuesday, January 24, 2017 4:45 PM
  • Hello Markus,

    I tested your code and for my ACER monitor it still grabs most but not all numbers for the serial number. Its a fairly new monitor so I don't know if the issue is monitor related, like if the EDID info that is embedded by manufacturer is accurate or not... I also have this issue with code as well.... is there another way decode the monitor serial numbers?


    Wednesday, May 10, 2017 7:11 PM
  • $ArrComputers = "localhost"
    $OutputLog = ".\output.log"
    $NotRespondingLog = ".\notresponding.log"
    $ErrorActionPreference = "Stop"
    Clear-Host

    $data = ForEach ($Computer in $ArrComputers) {
      try {
        $computerSystem = get-wmiobject Win32_ComputerSystem -Computer $Computer
        $computerBIOS = get-wmiobject Win32_BIOS -Computer $Computer
        $computerOS = get-wmiobject Win32_OperatingSystem -Computer $Computer
        $computerCPU = get-wmiobject Win32_Processor -Computer $Computer
        $computerHDD = Get-WmiObject Win32_LogicalDisk -Computer $Computer -Filter drivetype=3
        $Version = Get-WmiObject -Namespace "Root\CIMv2" `
            -Query "Select * from Win32_ComputerSystemProduct" `
            -computer $computer | select -ExpandProperty version
        $MonitorInfo = gwmi WmiMonitorID -Namespace root\wmi -computername  $computer |
          Select -last 1 @{n="Model"; e={[System.Text.Encoding]::ASCII.GetString($_.UserFriendlyName -ne 00)}},
            @{n="Serial Number";e={[System.Text.Encoding]::ASCII.GetString($_.SerialNumberID -ne 00)}}  
      } catch {
        $Computer | Out-File -FilePath $NotRespondingLog -Append -Encoding UTF8
        continue
      }


      $props = [ordered]@{
        'User' = $computerSystem.UserName
        'PC Serial Number'  = $computerBIOS.SerialNumber
        'CPU' = $computerCPU.Name
        'Model'          = $computerSystem.Model
        'HDDSize' = [math]::Round($computerHDD.Size/1GB)
        'RAM' = [math]::Round($computerSystem.TotalPhysicalMemory/1GB)
        'OS' = $computerOS.caption
        'PCName'         = $computerSystem.Name
        #'Version'        = $Version
        'Monitor Model'  = $MonitorInfo.Model
        'Monitor Serial' = $MonitorInfo."Serial Number"
        
      }
      New-Object -Type PSCustomObject -Property $props
    }

    $data | Export-Csv 'C:\Windows\Users\xxxx\Desktop\Monitor_system_info.csv' -NoType -Append

    # Open CSV file for review (leave this line out when deploying)
    notepad Workstation-inventory.csv
    Wednesday, May 10, 2017 7:13 PM
  • $ArrComputers = "localhost"
    $OutputLog = ".\output.log"
    $NotRespondingLog = ".\notresponding.log"
    $ErrorActionPreference = "Stop"
    Clear-Host

    $data = ForEach ($Computer in $ArrComputers) {
      try {
        $computerSystem = get-wmiobject Win32_ComputerSystem -Computer $Computer
        $computerBIOS = get-wmiobject Win32_BIOS -Computer $Computer
        $computerOS = get-wmiobject Win32_OperatingSystem -Computer $Computer
        $computerCPU = get-wmiobject Win32_Processor -Computer $Computer
        $computerHDD = Get-WmiObject Win32_LogicalDisk -Computer $Computer -Filter drivetype=3
        $Version = Get-WmiObject -Namespace "Root\CIMv2" `
            -Query "Select * from Win32_ComputerSystemProduct" `
            -computer $computer | select -ExpandProperty version
        $MonitorInfo = gwmi WmiMonitorID -Namespace root\wmi -computername  $computer |
          Select -last 1 @{n="Model"; e={[System.Text.Encoding]::ASCII.GetString($_.UserFriendlyName -ne 00)}},
            @{n="Serial Number";e={[System.Text.Encoding]::ASCII.GetString($_.SerialNumberID -ne 00)}}  
      } catch {
        $Computer | Out-File -FilePath $NotRespondingLog -Append -Encoding UTF8
        continue
      }


      $props = [ordered]@{
        'User' = $computerSystem.UserName
        'PC Serial Number'  = $computerBIOS.SerialNumber
        'CPU' = $computerCPU.Name
        'Model'          = $computerSystem.Model
        'HDDSize' = [math]::Round($computerHDD.Size/1GB)
        'RAM' = [math]::Round($computerSystem.TotalPhysicalMemory/1GB)
        'OS' = $computerOS.caption
        'PCName'         = $computerSystem.Name
        #'Version'        = $Version
        'Monitor Model'  = $MonitorInfo.Model
        'Monitor Serial' = $MonitorInfo."Serial Number"
        
      }
      New-Object -Type PSCustomObject -Property $props
    }

    $data | Export-Csv 'C:\Windows\Users\xxxx\Desktop\Monitor_system_info.csv' -NoType -Append

    # Open CSV file for review (leave this line out when deploying)
    notepad Workstation-inventory.csv

    Almost there but the output states that I have two monitors connected to my pc with the same model/serial number. Reality is that these are two different models...

    Kind regards,

    Thomas

    Thursday, May 11, 2017 8:50 AM