+ Post New Thread
Results 1 to 7 of 7
Promethean Direct Support Thread, Script to collect serial numbers in Direct Support; I wonder if anyone has a script that will trawl the network and pick up serial numbers from any boards ...
  1. #1

    garethedmondson's Avatar
    Join Date
    Oct 2008
    Location
    Gowerton, Swansea
    Posts
    2,271
    Thank Post
    965
    Thanked 325 Times in 193 Posts
    Blog Entries
    11
    Rep Power
    165

    Script to collect serial numbers

    I wonder if anyone has a script that will trawl the network and pick up serial numbers from any boards that are connected. Some boards do not show their serial number in the driver software so running a startup script would be an excellent way for me to do this across a large site.

    All I want are the following fields:

    <Machine Name> <Board Serial Number>

    Maybe it could be increased to have <Driver Version> <ActivStudio Version>

    I have no idea how to go about this. Over to you Promethean - I'm sure it would help a lot of people as well.

    Gareth

  2. #2

    Join Date
    Sep 2012
    Location
    United Kingdom
    Posts
    95
    Thank Post
    22
    Thanked 4 Times in 4 Posts
    Rep Power
    5
    This script should do the trick. It adds the Make, Model, Serial, MAC Address, and OS Version to the description field in Active Directory. Just save it as .VBS, you make have to delegate control so your machines can write to Active Directory.
    Code:
    Option ExplicitOn Error Resume Next
    
    
    Dim objRootDSE, objNetwork, objWMIService, objComputer
    Dim strComputer, strMake, strModel, strSerialNumber, strMacAddresses, strMemory, intMemory
    Dim colBIOS, objBIOS
    Dim colNetworkAdapterConfiguration, objNetworkAdapterConfiguration
    Dim colComputerSystem, objComputerSystem
    Dim colPhysicalMemory, objPhysicalMemory
    Dim adoConnection, adoRecordset
    dim mydatestring
    dim colOperatingSystems,objOperatingSystem,osver
    dim oReg, lastuser, snode, spath, svaluename, svalue
    dim colcpu, objItem, cpuspec
    dim objDisk, colDisks , cspace
    
    
    strComputer = "."
    strMemory = ""
    strMake = ""
    strModel = ""
    strSerialNumber = ""
    strMacAddresses = ""
    myDateString = Date()
    
    
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
        & strComputer & "\root\cimv2")
    Set colDisks = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    For Each objDisk in colDisks
         If objDisk.DeviceID = "C:" Then
             'Wscript.Echo "DeviceID: " & objDisk.DeviceID       
             cspace = int(objDisk.Size/1073741824) & " GB"
         end if
    Next
    
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colcpu = objWMIService.ExecQuery("Select * from Win32_Processor")
    For Each objItem in colcpu
        cpuspec = objItem.Name
    Next
    
    
    ' use "." for local computer
    sNode = "."
    
    
    Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
    
    
    On Error Resume Next
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
    & sNode & "/root/default:StdRegProv")
    
    
    If Err.Number <> 0 Then
    On Error Goto 0
    WScript.Echo "Could not connect to computer " & sNode
    Else
    On Error Goto 0
    sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"
    sValueName = "LastLoggedonUser"
    
    
    If oReg.GetStringValue(HKLM, sPath, sValueName, sValue) = 0 Then
    lastuser = sValue
    Else
    lastuser = "unknown" & sNode
    End If
    End If
    
    
    
    
    Set objRootDSE = GetObject("LDAP://RootDSE")
    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set objWMIService = GetObject("Winmgmts:\\" & strComputer & "\root\cimv2") 
    
    
    Set colComputerSystem = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") 
    Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
        osver = objOperatingSystem.Caption & " sp " & objOperatingSystem.ServicePackMajorVersion'& "  " & objOperatingSystem.Version
    Next
    
    
    If Not colComputerSystem Is Nothing Then
         For Each objComputerSystem In colComputerSystem 
            strMake = objComputerSystem.Manufacturer 
            strModel = objComputerSystem.Model 
        Next
    End If
    
    
    Set colBIOS = objWMIService.ExecQuery("Select * From Win32_BIOS")
    
    
    If Not colBIOS Is Nothing Then
         For Each objBIOS in colBIOS
             strSerialNumber = objBIOS.SerialNumber
         Next
    End If
    
    
    Set colNetworkAdapterConfiguration = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    
    
    strMacAddresses = ""
    
    
    If Not colNetworkAdapterConfiguration Is Nothing Then
         For Each objNetworkAdapterConfiguration in colNetworkAdapterConfiguration
             If strMacAddresses <> "" Then
                 strMacAddresses = strMacAddresses & ", "
             End If
             strMacAddresses = strMacAddresses & objNetworkAdapterConfiguration.MACAddress
         Next
    End If
    
    
    Set colPhysicalMemory = objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
    
    
    If Not colPhysicalMemory Is Nothing Then
         intMemory = 0
         For Each objPhysicalMemory In colPhysicalMemory
             intMemory = intMemory + Int(objPhysicalMemory.Capacity)
         Next
         strMemory = (intMemory / 1024 / 1024) & " MB"
    End If
    
    
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    
    
    If Err.Number <> 0 Then
         MsgBox "Connect Error: " & Err.Description
         WScript.Quit
    End If
    
    
    Set adoRecordset = adoConnection.Execute("<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Computer)(name=" & objNetwork.Computername & "));adspath;subtree")
    
    
    If Err.Number <> 0 Then
         MsgBox "Query Error: " & Err.Description
         WScript.Quit
    End If
    
    
    If Not adoRecordset.EOF Then
         Set objComputer = GetObject(adoRecordset.Fields(0).Value)
         objComputer.Put "description", "Make: " & strmake & ", Model: " &strModel & ", Serial No: " & strSerialNumber & ", MAC Address: " & strMACAddresses & ", OS: " & osver
         objComputer.SetInfo
    End If
    
    
    If Err.Number <> 0 Then
         MsgBox "Write Error: " & Err.Description
         WScript.Quit
    End If
    You can modify this line to remove some things reporting back like the MAC Address
    Code:
    objComputer.Put "description", "Make: " & strmake & ", Model: " &strModel & ", Serial No: " & strSerialNumber & ", MAC Address: " & strMACAddresses & ", OS: " & osver
    Last edited by OhDear; 20th September 2012 at 07:07 PM.

  3. #3

    garethedmondson's Avatar
    Join Date
    Oct 2008
    Location
    Gowerton, Swansea
    Posts
    2,271
    Thank Post
    965
    Thanked 325 Times in 193 Posts
    Blog Entries
    11
    Rep Power
    165
    Giving me a syntax error in line 1

    Gareth

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,730
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    Quote Originally Posted by garethedmondson View Post
    Giving me a syntax error in line 1

    Gareth
    Code:
    Option ExplicitOn Error Resume Next
    Should be

    Code:
    Option Explicit
    On Error Resume Next

    Steve

  5. #5

    garethedmondson's Avatar
    Join Date
    Oct 2008
    Location
    Gowerton, Swansea
    Posts
    2,271
    Thank Post
    965
    Thanked 325 Times in 193 Posts
    Blog Entries
    11
    Rep Power
    165
    A bit confused to where this saves information

    Help :-(

    Gareth

  6. #6

    garethedmondson's Avatar
    Join Date
    Oct 2008
    Location
    Gowerton, Swansea
    Posts
    2,271
    Thank Post
    965
    Thanked 325 Times in 193 Posts
    Blog Entries
    11
    Rep Power
    165
    Right - I see that it writes into AD - but I don't want the machine serial numbers. I wanted the script to query the ActivBoard and grab that serial number.

    GJE

  7. #7
    phillyrovers's Avatar
    Join Date
    Jul 2012
    Location
    Blackburn
    Posts
    107
    Thank Post
    2
    Thanked 34 Times in 31 Posts
    Rep Power
    10
    Hi garethedmundson,
    The script you are trying to create will not give you the desired results.
    The serial numbers that show up in the ActivDriver are not the serial numbers of the ActivBoards, but are the serial numbers of the electronics contained within the Activboard.
    The actual serial numbers of the Activboards are normally contained on a sticker located physically on the ActivBoard itself.

    Thank you

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 51
    Last Post: 4th July 2012, 08:51 AM
  2. Script to find serial numbers of all computers on network
    By bandgeekmafia78 in forum Scripts
    Replies: 3
    Last Post: 23rd May 2011, 05:11 PM
  3. [Windows Software] Which serial number to use for Server 2008 VM on datacenter 2008 licensed host ?
    By albertwt in forum Licensing Questions
    Replies: 2
    Last Post: 18th May 2010, 05:51 AM
  4. Replies: 18
    Last Post: 14th October 2005, 09:28 AM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 07:45 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •