Link to home
Start Free TrialLog in
Avatar of mystikal1000
mystikal1000

asked on

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

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
sSystem=Wscript.Arguments(0)
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
Next
Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

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
      Next

Next
ASKER CERTIFIED SOLUTION
Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mystikal1000
mystikal1000

ASKER

Does this find the serial numbers or model numbers on the servers or network adapters?
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.

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
    Wscript.Echo
    Wscript.Echo
Next
nEXT