Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to Collect Dell Service TAGS 1

Status
Not open for further replies.

STF26

IS-IT--Management
Dec 9, 2003
130
US
I found this great script that someone wrote to gather information about a user's PC and write it to a text file. Only one problem...

Serial Number: ÿÿÿÿÿ,

This is what I get when it outputs the Serial:

I was hoping to get something like: 2W2Y21S (my service Tag)

Thanks for any info.

Set FSO = CreateObject ("Scripting.FileSystemObject")
If FSO.FileExists("c:\pcaudit.txt") Then
Set F2 = FSO.OpenTextFile("c:\pcaudit.txt", 8)
Else
Set F2 = FSO.CreateTextFile ("c:\pcaudit.txt", 2)
End If

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem",,48)
Set colSN = objWMIService.ExecQuery ("Select SerialNumber from Win32_BIOS")
Set colNW = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For each objItem In colItems
F2.Write "UserName: " & objItem.Username
F2.Write ", System Name: " & objItem.Name
F2.Write ", Memory: " & objItem.TotalPhysicalMemory
Next
For each objBIOS in colSN
F2.Write ", Serial Number: " & objBios.SerialNumber
Next
For Each objAdapter in colNW
F2.Write ", NW Adaptor Description: " & objAdapter.Description
F2.Write ", Ip Address: " & objAdapter.IPAddress(i)
F2.WriteLine ", MAC Address: " & objAdapter.MACAddress
Next



F2.Close
WScript.Quit
 
Code:
'==========================================================================
'
' NAME: <MemProcDiskSoftwareInventory.vbs>
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 5/15/2003
'
' COMMENT: <Inventories computer configuration and writes report to disk>
' Modifications:
' 6/4/2004 added support to look for ALL local hard drives.
' 3/18/2005 added support to grab Dell Service Tag number.
'==========================================================================
on error resume Next

Set oShell = CreateObject("wscript.Shell")
Set env = oShell.environment("Process")
strComputer = env.Item("Computername")
Const HKEY_LOCAL_MACHINE = &H80000002
Const UnInstPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

report = strComputer & " Computer Inventory" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
	If objSMBIOS.SerialNumber <> "" Then
    	report = report &  "Dell Service Tag: "  & objSMBIOS.SerialNumber & vbCrLf
    End If
Next




Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "OS Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objItem in colItems
	report = report &  strComputer  & vbCrLf & "OS Details"& vbCrlf
    report = report &  "Caption: " & objItem.Caption & vbCrLf
    report = report &  "Description: " & objItem.Description & vbCrLf
    report = report &  "EncryptionLevel: " & objItem.EncryptionLevel & vbCrLf
    report = report &  "InstallDate: " & objItem.InstallDate & vbCrLf
    report = report &  "Manufacturer: " & objItem.Manufacturer & vbCrLf
    report = report &  "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses & vbCrLf
    report = report &  "Name: " & objItem.Name & vbCrLf
    report = report &  "Organization: " & objItem.Organization & vbCrLf
    report = report &  "OSProductSuite: " & objItem.OSProductSuite & vbCrLf
    report = report &  "RegisteredUser: " & objItem.RegisteredUser & vbCrLf
    report = report &  "SerialNumber: " & objItem.SerialNumber & vbCrLf
    report = report &  "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion & vbCrLf
    report = report &  "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion & vbCrLf
    report = report &  "Version: " & objItem.Version & vbCrLf
    report = report &  "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Memory Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each objComputer in colSettings 
'report = report & objComputer.Name & vbcrlf
report = report & objComputer.TotalPhysicalMemory /1024\1024+1 & "MB Total memory" & vbcrlf
Next
report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Processor Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf


Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_Processor",,48)

Dim procdic, arrayitems,arraykeys, i 
Set procdic = CreateObject("Scripting.Dictionary")

For Each objProcessor in colSettings
procdic.Add "ID",objProcessor.Description 
procdic.Add "Manufacturer",objProcessor.Manufacturer
procdic.Add "MHz", objProcessor.MaxClockspeed
procdic.Add "Name", objProcessor.Name
Next

arraykeys = procdic.Keys
arrayItems = procdic.Items
For i = 0 to procdic.Count -1
	report = report & arrayKeys(i)& ":" & arrayItems(i) &vbCrLf
Next  


report = report & vbCrLf & "******************************************" & vbCrLf
report = report & "Disk Drive Information" & vbCrLf & "******************************************" & vbCrLf & vbCrLf

Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where DriveType = '3'",,48)
For Each objItem in colItems
    report = report & "Drive: " & objItem.Caption & vbCrLf 
    report = report & "VolumeSerialNumber: " & objItem.VolumeSerialNumber& vbCrLf 
    report = report & "Description: " & objItem.Description& vbCrLf 
    report = report & "Size: " & objItem.Size /1024\1024+1 & "MB Total Disk Space" & vbCrLf
    report = report & "Free Space: " & objItem.FreeSpace /1024\1024+1 & "MB Free Disk Space" & vbCrLf& vbCrLf 

Next



oReg.EnumKey HKEY_LOCAL_MACHINE, UnInstPath, arrSubKeys
software = vbCrLf & "******************************************" & vbCrLf
software = software & "Installed Software" & vbCrLf & "******************************************" & vbCrLf & vbCrLf
For Each subkey In arrSubKeys
'MsgBox subkey
If Left (subkey, 1) <> "{" Then
	software = software & subkey & vbCrLf
End If
Next

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)
ts.write report
ts.write software
MsgBox "Done"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Thanks for your response. I ran the script on my Dell Notebook and Did not get the service Tag. The Computer Area is blank. Where should the TAG show up?
 
Hmm, that works on mine. I have the script set to not list Dell Service Tag if the data is blank. Try running this on another computer. Yours may just not have it set for some reason.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Mark, you were right, my notebook does not have a service tag because I replaced the motherboard once. I ran the script on another piece of equipment and it works great. Thanks!

If I wanted to gather information about the machines on my network what would be the best way to do this? If I put the script in a users startup folder can I redirect where the output goes? Is there a way to run the script up against many machines? Thanks!
 
Yes, you could direct the file to wherever you want. Modify the line:
Code:
Set ts = fso.CreateTextFile (strComputer & ".txt", ForWriting)

to be something like:
Code:
Set ts = fso.CreateTextFile ([b]"x:\" & [/b]strComputer & ".txt", ForWriting)

You should also check out my FAQ faq329-4871 for information on how to modify this script to run against multiple computers. Essentially you need to swap out the line:
Code:
strComputer = env.Item("Computername")
for code that will fill in the machine name as a variable and enclose the whole script into a For next. I explain this all in my FAQ so have fun.


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top