/build/static/layout/Breadcrumb_cap_w.png

Monitor serial numbers

Hi there,

Has anyone had success with retrieving monitor serial numbers remotely and have them add to inventory?

if so, how did you do it?

Many thanks


0 Comments   [ + ] Show comments

Answers (2)

Posted by: flip1001 11 years ago
Black Belt
0

I modified the script from robvanderwoude.com I mentioned above to output a textfile to C:\Windows\Temp\KACE-Monitor-info.txt. I also made a custom inventory rule to return the fileinfo of that file.

It shows up in the custom inventory, but double spaced. So the only improvements it could use would be to come up single spaced, and also for some reason on my home PC, it shows 2 monitors (with same SN).

Here is the modified script.

' Script modified from
' http://www.robvanderwoude.com/files/dispedid_vbs.txt

Option Explicit

Dim blnControl
Dim i, j, k
Dim arrControl, arrKeys, arrRawEDID, arrSubKeys
Dim objReg, wshShell, objFso
Dim strComputer, strDeviceDesc, strMfg, strModel, strMsg, strKeyPath, strSerial, strSubKeyPath, strSubSubKeyPath
Dim strOutputFile, objOutputFile

'Hive Constants
Const HKEY_CLASSES_ROOT       = &H80000000
Const HKEY_CURRENT_USER       = &H80000001
Const HKEY_LOCAL_MACHINE      = &H80000002
Const HKEY_USERS              = &H80000003
Const HKEY_PERFORMANCE_DATA   = &H80000004
Const HKEY_CURRENT_CONFIG     = &H80000005
Const HKEY_DYN_DATA           = &H80000006

'RegFormat Constants
Const REG_NONE                = 0
Const REG_SZ                  = 1
Const REG_EXPAND_SZ           = 2
Const REG_BINARY              = 3
Const REG_DWORD               = 4
Const REG_DWORD_LITTLE_ENDIAN = 4
Const REG_DWORD_BIG_ENDIAN    = 5
Const REG_LINK                = 6
Const REG_MULTI_SZ            = 7
Const REG_RESOURCE_LIST       = 8

'FileSystemObject OpenTextFile constants
Const ForReading              = 1
Const ForWriting              = 2
Const ForAppending            = 8

If WScript.Arguments.Count > 0 Then Syntax

strComputer = "."
strMsg      = ""

On Error Resume Next
Set objReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:StdRegProv" )

strKeyPath = "SYSTEM\CurrentControlSet\Enum\DISPLAY"
objReg.EnumKey  HKEY_LOCAL_MACHINE, strKeyPath, arrKeys

If IsArray( arrKeys ) Then
  For i = 0 To UBound( arrKeys )
    strSubKeyPath = strKeyPath & "\" & arrKeys( i )
    objReg.EnumKey  HKEY_LOCAL_MACHINE, strSubKeyPath, arrSubKeys
    If IsArray( arrSubKeys ) Then
      For j = 0 To UBound( arrSubKeys )
        strSubSubKeyPath = strSubKeyPath & "\" & arrSubKeys( j )
        objReg.EnumKey  HKEY_LOCAL_MACHINE, strSubSubKeyPath, arrSub2
        blnControl = False
        If IsArray( arrSub2 ) Then
          For k = 0 To UBound( arrSub2 )
            If arrSub2(k) = "Control" Then blnControl = True
          Next
        End If
        If blnControl Then
          objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubSubKeyPath, "Mfg", strMfg
          If IsNull( strMfg ) Then strMfg = "unknown"
            If InStr( strMfg, ";" ) Then strMfg = Mid( strMfg, InStr( strMfg, ";" ) + 1 )
              objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubSubKeyPath, "DeviceDesc", strDeviceDesc
          If InStr( strDeviceDesc, ";" ) Then strDeviceDesc = Mid( strDeviceDesc, InStr( strDeviceDesc, ";" ) + 1 )
            objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strSubSubKeyPath & "\Device Parameters", "BAD_EDID", arrBadEDID
          If Not IsArray( arrBadEDID ) Then
            objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strSubSubKeyPath & "\Device Parameters", "EDID", arrRawEDID
            If IsArray( arrRawEDID ) Then
              Test 54
              Test 72
              Test 90
              Test 108
            End If
            If ((strSerial <> vbNull) And (strSerial <> "")) Then
              If StrMsg = "" Then
                strMsg = "Manufacturer: " & strMfg & vbCrLf _
                & "Description: " & strDeviceDesc & vbCrLf _
                & "Model (EDID): " & strModel & vbCrLf _
                & "Serial# (EDID): " & strSerial & vbCrLf
              Else
                strMsg = strMsg & vbCrLf _
                & "Manufacturer: " & strMfg & vbCrLf _
                & "Description: " & strDeviceDesc & vbCrLf _
                & "Model (EDID): " & strModel & vbCrLf _
                & "Serial# (EDID): " & strSerial & vbCrLf
              End If
            End If
          End If
        End If
      Next
    End If
  Next
End If

If ((StrMsg = vbNull) Or (StrMsg = "")) Then
  WScript.Quit
End If

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")

strOutputFile = "C:\Windows\Temp\KACE-Monitor-info.txt"

If objFso.FolderExists("C:\windows\temp") then
  set objOutputFile = objFso.OpenTextFile(strOutputFile, ForWriting, True)
  'WScript.Echo strMsg
  objOutputFile.Write strMsg
  objOutputFile.Close
End If

Sub Test( ByVal myIndex )
  Dim idx, arrTemp, arrTestModel, arrTestSerial, blnModel, blnSerial, strTemp
  arrTestModel  = Split( "0 0 0 252" )
  arrTestSerial = Split( "0 0 0 255" )
  blnModel      = True
  blnSerial     = True

  For idx = 0 To 3
    If CInt( arrTestModel( idx )  ) <> CInt( arrRawEDID( idx + myIndex ) ) Then blnModel  = False
    If CInt( arrTestSerial( idx ) ) <> CInt( arrRawEDID( idx + myIndex ) ) Then blnSerial = False
  Next

  If blnModel Or blnSerial Then
    For idx = 4 To 17
      Select Case arrRawEDID( myIndex + idx )
        Case 0
          strTemp = strTemp & " "
        Case 7
          strTemp = strTemp & " "
        Case 10
          strTemp = strTemp & " "
        Case 13
          strTemp = strTemp & " "
        Case Else
          strTemp = strTemp & Chr( arrRawEDID( myIndex + idx ) )
      End Select
    Next
    strTemp = Trim( strTemp )
    ' The following lines are disabled because they truncate model names at the first space
    'If InStr( strTemp, " " ) Then
    '  arrTemp = Split( strTemp, " " )
    '  strTemp = arrTemp(0)
    'End If
    If blnModel  Then strModel  = strTemp
    If blnSerial Then strSerial = strTemp
  End If
End Sub

Sub Syntax
  strMsg = vbCrLf _
    & "DispEDID.vbs,  Version 2.30" _
    & vbCrLf _
    & "Read and parse monitor EDID asset information from the registry" _
    & vbCrLf & vbCrLf _
    & "Usage:  DISPEDID.VBS" _
    & vbCrLf & vbCrLf _
    & "Based on a script by Michael Baird (link no longer available)" _
    & vbCrLf & vbCrLf _
    & "(Re)written by Rob van der Woude" _
    & vbCrLf _
    & "http://www.robvanderwoude.com"
  ' WScript.Echo strMsg
  WScript.Quit 1
End Sub




Comments:
  • this is awesome... how can I get this txt file info into a custom inventory rule? - binuani 11 years ago
  • I created a custom inventory field:

    Display Name (title): Monitor Serial Number
    Publisher (Vendor): My Company (replace this with yours)

    Supported OS: Windows - I picked all Windows I saw, except Windows 2000. Because I have very few of those left < 1%. If you need Win2k support, the script would need to be modified and also the custom inventory rule.

    Custom Inventory Rule:
    FileExists(C:\Windows\Temp\KACE-Monitor-info.txt) AND ShellCommandTextReturn(cmd /c type C:\Windows\Temp\KACE-Monitor-info.txt)

    For the script I put it as an offline kscript. - flip1001 11 years ago
    • I agree this is awesome... but we've only had our kbox for a few months and i havent learned to do scripts before today (the auditor is here for a month :( uggg) Is there a comprehensive import vbs scripts to kace script somewhere?

      I am able to run the above script from a pc (not from kace console) and get the resulting text file to show in kace custom inventory field.

      I just cant figure out how to combine the above script with the:

      "The following is an example of the XML structure for an appliance script:
      <?xml version="1.0" encoding="utf-8" ?>
      <kbots xmlns="http://kace.com/Kbots.xsd">
      <kbot>
      <config name="name="" type="policy" id="0" version="version="" description="description="">

      <execute disconnected="false" logged_off="false">
      </execute>

      </config>
      <compliance>
      </compliance>
      </kbot>
      </kbots>"

      requirement from the Creating and editing scripts help section. How can do? - OmegaDave 11 years ago
  • After seeing the script in action I see some potential drawbacks:

    The monitor sn will not be unique in the custom inventory fields, because if a computer monitor was not uninstalled on a PC before removal, it will still show up in the registry.

    Also, the monitor may show up on a lot of computers registry if it was on the master sysprep image.

    I plan to test out Extron EDID manager to see if it reads from the monitor EDID instead of the windows registry.

    http://www.extron.com/product/software.aspx?id=edidmanager - flip1001 11 years ago
Posted by: jdornan 11 years ago
Red Belt
0

Here is a vbscript that will get that info. 

Capture the output to a txt file and use in a custom inventory rule

 

  Set wshShell = WScript.CreateObject( "WScript.Shell" )
 strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) 
 WScript.Echo "Computer Name: " & strComputerName 
 Set objWMIService = GetObject("winmgmts:\\" & strComputerName & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_ComputerSystemProduct",,48) theValue = "" For Each objItem in colItems theValue = objItem.IdentifyingNumber Next 
 getPCSerialNumber = theValue WScript.Echo "Serial Number: " & theValue
 

Comments:
  • Probably the best solution would be Monitor Asset Manager from EnTech Taiwan. It reads the EDID directly from the monitor. But it also costs $1 per user according to http://www.entechtaiwan.com/util/moninfo.shtm

    Some alternatives that may work are DumpEDID from www.nirsoft.net/utils/dump_edid.html, or this script from http://www.robvanderwoude.com/files/dispedid_vbs.txt.

    These will read from the registry, which may not be entirely accurate. The reg entries are under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY.

    For instance, DumpEDID returns 2 results even though I have 1 monitor. The results for the monitor model and sn are the same, but the registry keys are slightly different. I believe this is because I updated the driver for my monitor instead of uninstalling it.

    The script will probably be better because you can easily modify it to write to a text file and then read that file with a Custom Inventory rule. But I haven't tried the script on a dual monitor setup so I don't know if it works completely.

    All this info for Windows only. - flip1001 11 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ