Sponsored Links

Login Form






Lost Password?

Syndicate

Home arrow RSS Feeds
Query Dell Service Tag: Revised PDF Print E-mail
User Rating: / 5
PoorBest 
Written by Cheyenne Harden   
This is an update to the previous script "Query Dell Service Tag".
I couldn't leave well enough alone...
The LazyNetworkAdmin defined his script as,
"Because most of the computers I work on are Dell's,
a lot of times I need to look up the service tag for a specific machine.
Without the need of bulky software, you can easily use WMI to gather this information.
This article will show you how to remotely query your dell pc's for their service tags."

----------COPY EVERYTHING BELOW THIS LINE----------

On Error Resume Next
Const ForWriting = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")
strDomain = "YOUR_DOMAIN_HERE" ' Your Domain (e.g., monster.com)
strPCsFile = "Service_Tag.txt"
strPath = "C:\scripts\" ' Create this folder
strWorkstationID = "C:\scripts\Service_Tag.txt"
i = 0

'#########
Set objFSO3 = CreateObject("Scripting.FileSystemObject")

If objFSO3.FileExists(strPath & strPCsFile) Then
 Set objFolder = objFSO3.GetFile(strPath & strPCsFile)

Else
  Set objFSOf = CreateObject("Scripting.FileSystemObject")
  If objFSOf.FolderExists(strPath) Then
   Set objFolder = objFSOf.GetFolder(strPath)
  Else
   Set objFolder = objFSO3.CreateFolder(strPath)
  End If
 Set objFile1 = objFSO3.CreateTextFile(strPath & strPCsFile)
 objFile1.Close

End If
'#########

Wscript.Echo "This program will return the Dell Service Tag on remote computer(s)"
strMbox = MsgBox("Would you like info for the entire domain: Matrixsvr ?",4,"Hostname")

If strMbox = 6 Then
'Set objPCTXTFile = objFSO.OpenTextFile(strPath & strPCsFile, ForWriting, True)
Set objDomain = GetObject("WinNT://" & strDomain) ' Note LDAP does not work
objDomain.Filter = Array("Computer")
For Each pcObject In objDomain 
objDictionary.Add i, pcObject.Name
'Wscript.Echo objDictionary(i)
i = i + 1

Next

For each DomainPC in objDictionary
strComputer = objDictionary.Item(DomainPC)
GetWorkstationID()
Next

Set objFilesystem = Nothing

WScript.echo "Finished Scanning Network check : " & strPath

Else
strHost = InputBox("Enter the computer you wish to find the Dell Service Tag from","Hostname"," ")
GetWorkstationID2()
End If

Sub GetWorkstationID()

On Error Resume Next

Set objWMIservice = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colitems = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
For each objitem in colitems
 
      strWriteFile = strComputer &"   Dell Service Tag: " & objitem.serialnumber

Next
'#############

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(strPath & strPCsFile, ForWriting, True)
objOutputFile.WriteLine(strWriteFile)
objOutputFile.Close

'#############
End Sub

Sub GetWorkstationID2()

On Error Resume Next
Wscript.echo strComputer & ": " & objitem.serialnumber
Set objWMIservice = GetObject("winmgmts:\\" & strHost & "\root\cimv2")
set colitems = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
For each objitem in colitems

      Wscript.echo "Computer: " & strHost & "   Dell Service Tag: " & objitem.serialnumber
   strWriteFile = "Computer: " & strHost &"   Dell Service Tag: " & objitem.serialnumber

   Next
'%%%%%%%%%%

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(strPath & strPCsFile, ForWriting, True)
objOutputFile.WriteLine(strWriteFile)
objOutputFile.Close

'%%%%%%%%%%
End Sub


----------COPY EVERYTHING ABOVE THIS LINE----------

PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!

To make this script work you will need two things!


1. You will need to have Admin privlidges on the target computers.
2. You will need the name of your domain (e.g., strDomain = "YOUR_DOMAIN_HERE" ' Your Domain (e.g., monster.com))

This information is provided "AS IS" with no warranties expressed or implied.

Comments
Add New
caz   |212.85.1.1 |26-11-2008 10:20:17
Runs, then closes...nothing..
caz   |212.85.1.1 |26-11-2008 10:33:13
Does work, my mistake. a quick note to say save as .vbs is helpful if your new
to site however.
Warey   |217.40.31.138 |18-12-2008 06:41:20
Great script for a whole domain, but I only need to query a specific OU. can
this be modified to do that?
Write comment
Name:
Email:
 
Title:
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
Tag it:
Delicious
Furl it!
Spurl
digg
YahooMyWeb
< Prev   Next >
 

Google Search

Google