How do I get system serial number using WMI for list of servers.

Posted on 2006-05-22
Last Modified: 2008-01-16
I am looking for a quick way to collect serial numbers from Windows 2000 and greater servers using an external host file.

I have a text file that has server names in it. I want to either run a VBS command or some other command that will read the text host file, query the server then output to another file the servers name, serial number, model number, then go to the next one until the end of the file.

Also, if it doesn't find the server then put in the words "not online" instead of a serial number.

I have this script that will retrieve the serial number one at a time, but would like something I described above?

On Error Resume Next
Dim System
if Wscript.Arguments.Count >0 then
end if
ComputerName = InputBox("Enter the name of the computer you wish to query")
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject( winmgmt1 ).InstancesOf ("Win32_BIOS")
for each SN in SNSet
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber
Question by:mystikal1000
    LVL 33

    Expert Comment

    You can use an array...for example:

    Computers = array("server1", "server2", "server3")

    For each Computer in Computers
       on error resume Next
       Set objWMIService = GetObject("winmgmts://" & Computer & "\root\cimv2")
       Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
       n = 1

            For Each objAdapter in colAdapters

                WScript.Echo objAdapter.DNSHostName & "," & objAdapter.WINSPrimaryServer & "," & objAdapter.WINSSecondaryServer
                  n = n + 1

    LVL 33

    Accepted Solution

    Or an example of using a text file:

    Const ForReading = 1
    Set objDictionary = CreateObject("Scripting.Dictionary")
    Set objFSO = CreateObject("Scripting.FilesystemObject")
    Set ObjtextFile = objFSO.Opentextfile("Y:\vbscripts\WindowsScripts\Joe_test\serverlist.txt", ForReading)

    i = 0
    Do Until objtextfile.AtEndOfStream
          objdictionary.add i, strnextline

    For each objitem in objdictionary
       Strcomputer = objdictionary.item(objitem)
          wscript.echo strcomputer      
       Set objWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!\\"  & strcomputer& "\root\cimv2")
       Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
       n = 1

            For Each objAdapter in colAdapters

                strOutput = strOutput & strComputer & ","

    If Not IsNull(objAdapter.IPAddress) Then
    For i = 0 To UBound(objAdapter.IPAddress)
    strOutput = strOutput & objAdapter.IPAddress(i)
    If i <> UBound(objAdapter.IPAddress) Then
    strOutput = strOutput & " "
    strOutput = strOutput & ","
    End If
    End If

    strOutput = strOutput & objAdapter.MACAddress & ","
    strOutput = strOutput & objAdapter.WINSPrimaryServer & ","
    strOutput = strOutput & objAdapter.WINSSecondaryServer & ","

    If Not IsNull(objAdapter.DNSServerSearchOrder) Then
    For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
    strOutput = strOutput & objAdapter.DNSServerSearchOrder(i) & ","
    End If

    If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
    For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
    strOutput = strOutput & objAdapter.DNSDomainSuffixSearchOrder(i) & ","
    End If

    strOutput = strOutput & objAdapter.Description & ","

    objOutputFile.Writeline strOutput
    strOutput = "Y:\vbscripts\WindowsScripts\Joe_test\output.txt"

    n = n + 1

    Set objAdapter = Null
    Set colAdapters = Null
    objAdapter = Nothing
    colAdapters = Nothing




    Author Comment

    Does this find the serial numbers or model numbers on the servers or network adapters?
    LVL 33

    Expert Comment

    no... this is an example of how to use a TEXT file in a vbscript... or how to enter mulitple server names inside the script.
    LVL 33

    Expert Comment


    Computers = array("server1","server2","server3")

    For each Computer in Computers
    On Error Resume Next

    Set objWMIService = GetObject("winmgmts:\\" & computer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
    For Each objItem in colItems
        Wscript.Echo "BiosCharacteristics: " & objItem.BiosCharacteristics
        Wscript.Echo "BIOSVersion: " & objItem.BIOSVersion
        Wscript.Echo "BuildNumber: " & objItem.BuildNumber
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "CodeSet: " & objItem.CodeSet
        Wscript.Echo "CurrentLanguage: " & objItem.CurrentLanguage
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "IdentificationCode: " & objItem.IdentificationCode
        Wscript.Echo "InstallableLanguages: " & objItem.InstallableLanguages
        Wscript.Echo "InstallDate: " & objItem.InstallDate
        Wscript.Echo "LanguageEdition: " & objItem.LanguageEdition
        Wscript.Echo "ListOfLanguages: " & objItem.ListOfLanguages
        Wscript.Echo "Manufacturer: " & objItem.Manufacturer
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "OtherTargetOS: " & objItem.OtherTargetOS
        Wscript.Echo "PrimaryBIOS: " & objItem.PrimaryBIOS
        Wscript.Echo "ReleaseDate: " & objItem.ReleaseDate
        Wscript.Echo "SerialNumber: " & objItem.SerialNumber
        Wscript.Echo "SMBIOSBIOSVersion: " & objItem.SMBIOSBIOSVersion
        Wscript.Echo "SMBIOSMajorVersion: " & objItem.SMBIOSMajorVersion
        Wscript.Echo "SMBIOSMinorVersion: " & objItem.SMBIOSMinorVersion
        Wscript.Echo "SMBIOSPresent: " & objItem.SMBIOSPresent
        Wscript.Echo "SoftwareElementID: " & objItem.SoftwareElementID
        Wscript.Echo "SoftwareElementState: " & objItem.SoftwareElementState
        Wscript.Echo "Status: " & objItem.Status
        Wscript.Echo "TargetOperatingSystem: " & objItem.TargetOperatingSystem
        Wscript.Echo "Version: " & objItem.Version

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
    On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now