6 Posts

January 29th, 2004 19:00

There are a few ways to do this. SMTP may not the best idea.

This is a VBscript I wrote to pull the service tag out of the windows WMI system.

Copy the text and paste it into notpad. Save the file with a .VBS Extenion and then doble click it. Enter the name or IP of the computer you want to get the service tag information from. The script will ask the other computer it's service tag info.

Start script (copy below this line)

strComputer = inputbox("Type the name of the computer with out \\ or an IP address to find out the service tag")

if strComputer = "" then wscript.quit

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
    Wscript.Echo "Service tag (serial number): " & objSMBIOS.SerialNumber
Next

stop script (copy above this line)

I wrote a whole inventory system around this. It imports the data it collects into an SQL database

You need administrator access to the other computer for this to work.

you mod this to take a range of IP addresses and dump it to a text file..

Message Edited by Thewhip on 01-29-2004 04:50 PM

Message Edited by Thewhip on 01-29-2004 04:50 PM

2 Posts

January 30th, 2004 12:00

Wow that worked perfectly, thanks for your support that is very appreciated. Now I think big, there's someone here who's good programmer. I'll ask him to integrated codes to the VBScript so that I can use logon scripts to collect ST and build a database with the collected information. Thanks again !

2 Posts

March 24th, 2004 17:00

I am so glad to find someone else with the same issue!!  I too need to gather all the service tags for all 500 computers in my company. We have been working with wsh and vb since I read your posting and are having some issues being able to read from a .txt file and dump the service tag and computer name into another .txt file. Could you send me what you guys did? This would be a great help.

6 Posts

March 24th, 2004 18:00

I wrote my script to get info for 750 computers in my building. Now we use it on are 11,000 computers all over are company.

I'll write you a script to grab your IP addresses out of a text file and put serial numbers and the computer name into another text file. (I’m guessing that’s what your trying to do?)

The problem with text files is they are not updated they are added to. This causes duplicates in the file. If you’re fine with that then cool with me.

The cool thing about a database is that you can update the record and add new entries only. So if you have access to an SQL server (you might be able to use Linux and mysql but I don’t know) then you can set up your script to sent its results to a database and only add new computers it finds.  Getting the data from the database is another project In it’s self. give me a day


 

Message Edited by Thewhip on 03-24-2004 03:37 PM

2 Posts

March 25th, 2004 10:00

Yeah that is exactly what I am trying to do.  Can you send me the script via email.  I will send you a private message with my email through the Dell Forum you can check that through the "private messages" link at the top.  Thanks, DJ 

1 Message

April 13th, 2004 15:00

That is a great little script...any chance you can send me the mods so I can scan from a list of names in a text file?  Also what mods will I have to make to dump it into a SQL database?  Any help would be great!!!

 

Kilted_One

6 Posts

April 13th, 2004 20:00

Yeah I'll hook ya up.  Send me a private message and I'll E-mail it to you for the SQL (I might have some questions about your setup)

I'll post the other script I wrote here that dumps to a text file. It has a bug and it hangs some times. but it should work. most of the time.

I never got any other feed back on this script for the last guy to post who I wrote it for. 

Start copy below this line _____________________________________

 

on error resume next
'geting input from the users on the names of the text files to pull and put the info

V_textfileforinput = inputbox("Type the full path of your input text file. This file should be a list of IP addresses or computer names of the computers you wish to find out the service tags")
V_textfileforoutput = inputbox("Type the full path of your output text file.",,"c:\outputSNlist.txt")

'Opens the input file
set objfso = wscript.createobject("scripting.filesystemobject")
set objstream = objfso.opentextfile(V_textfileforinput)

'makes and opens the output file it will apend the file if it's all ready there
set objFileSystem = createobject("Scripting.FileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(V_textfileforoutput, 2, True)

'starts at the top of the open Input file reading on line at a time.  this is where the script loops to
do while not objstream.atendofstream
'resets the variables
 V_PCNAME = ""
 V_PCSERIAL = ""
 v_inputline = ""
 v_inputline = objstream.readline


'Ping Ip or computer name to check to an alive computer

 dim wshShell, fso, tfolder, tname, TempFile, results, retString, ts
 
 reachable = false
 set wshShell=wscript.createobject("wscript.shell")
 set fso = CreateObject("Scripting.FileSystemObject")
 wshShell.run "cmd /c ping -n 1 -w 10 " & v_inputline & "> c:\tempfile1.txt" ,0,true
 set results = fso.GetFile("c:\tempfile1.txt")
 set ts = results.OpenAsTextStream(1)
 do while ts.AtEndOfStream <> True
  retString = ts.ReadLine
  'wscript.echo "Readline= " & retString
  if instr(retString, "Request timed out.") then
   reachable = "false"
   exit do
  end if
 loop
 ts.Close


 if reachable = "false" then
  'wscript.echo v_inputline & " is Dead"
  V_state = "No Reply"
 else
  'wscript.echo v_inputline & " alive"
  V_state = "Good IP"
  if len(V_STRCOMPUTER) < 2 then

  
  'gets the informations from the pc

   Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & v_inputline & "\root\cimv2")
   Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
   For Each objSMBIOS in colSMBIOS
    V_PCSERIAL = objSMBIOS.SerialNumber
   Next


   Set SystemSet = GetObject("winmgmts://"& v_inputline ).InstancesOf ("Win32_ComputerSystem")

   for each System in SystemSet
    V_PCNAME = System.Name
    V_USERID = system.username
    V_PCTYPE = system.Model
    V_RAMSIZE = system.TotalPhysicalMemory
    V_RAMSIZE = (V_RAMSIZE / 1024) * .001
    V_RAMSIZE = round(V_RAMSIZE) & " MB"
   next

  'sets up the info for the output line
   outline = v_inputline & " " & V_state & " " &  V_PCSERIAL & " " & V_PCNAME
   'wscript.echo outline 'this line can be on commented if you want to see the output
   objOutputFile.WriteLine outline
   
   Set objFileSystem = Nothing

  else
  end if

 end if
set objWMIService = Nothing
set colSMBIOS = Nothing
set systemset = Nothing


loop
wscript.echo "The scripts is done. Check " & V_textfileforoutput & " for the data the script collected"
objOutputFile.Close

 

Stop copy_________________________________________________

 

 

 

2 Posts

April 19th, 2004 18:00

The program looks great, but when I save it with a VBS extension and I run it from a command prompt or double click on it, it just opens the script up into notepad.  I am trying to use on Windows 2000 or NT.  Do I have to enable VBS scripting?  Thanks for your help and sharing your code.

1 Message

April 20th, 2004 02:00

If you are using XP then you have to turn on the known file extensions in the folders options.  Otherwise, it adds the extension to the file name and does not change it from notepad.  When you turn it, the file extensions your file will look like this filename.vbs.txt just remove the .txt from the end and it should work.

Thank you for the post on getting the Service Tags, it will be a great help.  I have 17 locations that I administer and trying to get that information is extremely difficult.

1 Message

April 20th, 2004 11:00

Is it possible to fid the IP address from the service tag.  I have two computers that I can't find.  I know the service tags, and would like to know if they are connected to my network somewhere.

2 Posts

April 20th, 2004 11:00

Thanks.  The script did have a VBS extenstion but the association was with notepad.  I changed the association to cscript.exe and it works great.  Thanks again!

32 Posts

April 30th, 2004 14:00

is there any way to write a VB program to extract the asset tag and the purchase date?

 

 

Many thanks Sandy

1 Message

June 8th, 2004 11:00

I have a rather unique challenge.  I have a stack of laptops to be distributed to students and I need them all to have a unique name specifically in the format, "ITAP- ".  Is there a variable I can insert that places each system's Service Tag here?  I want to use a batch file to run and change the name of the computer and the following registry values to the above format, but I am unfamiliar with batch files and I have had little luck finding one that will allow me to edit the registry.  Any help would be appreciated.

~JWoot

2 Posts

September 12th, 2012 18:00

Hi Whip. Do you hav eany idea how I could edit this script to pull computer names by using the service tag or aka serial numbers from Dells in our Network? Thanks in advance

2 Intern

 • 

793 Posts

September 13th, 2012 17:00

JWoot,

You can use the command, "wmic bios get serialnumber" to return the service tag, save it to a variable, and then use that to create the system name.  For servers, there is probably an omreport command, but the wmic one will work too.

No Events found!

Top