| Login

Search this Blog


Links I like to keep around




Here are the most recent postings to this blog. Use the archive calendar or search to find other entries.
Nov17

Written by:R Teachout
11/17/2006 3:18 AM

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' File:     DellSetAssetTag.vbs
' Updated:  May 2003
' Version:  1.0
' Author:   Dan Thomson, myITforum.com columnist
'           I can be contacted at dethomson@hotmail.com
'
' Purpose:  To set the asset tag for a Dell OMCI client.
'
' Usage:    cscript.exe DellSetAssetTag.vbs
'
' Input:    systemname    Name of system to modify
'           assettag      Asset tag to be assigned
'
' Requirements:
'           - Dell Open Manage Client (see below for tested version)
'           - Windows Script
'             http://msdn.microsoft.com/library/default.asp?url=/downloads
'             /list/webdev.asp
'           - WMI version 1.5
'
' Notes:
'           Tests performed using:
'           Windows 2000 Professional
'           Windows Script v5.6
'           Dell Open Manage Client version 6.1.1.259
'           Optiplex GX240 & GX260 ( success )
'           Inspiron 5000 ( N/A )
'           Precision 530MT ( success )
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit
On Error Resume Next

'*** Declare variables
Dim strNameSpace
Dim strComputerName
Dim strClassName
Dim colInstances
Dim objInstance
Dim strWQLQuery
Dim strKeyName
Dim strAssetTag

'*** Check that the right executable was used to run the script
'*** and that all parameters were passed
If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Or _
  (Wscript.Arguments.Count < 2) Then
  Call Usage()
  WScript.Quit(-1)
End If

'*** Initialize variables
strNameSpace    = "root/Dellomci"
strComputerName = WScript.Arguments(0)
strClassName    = "Dell_SystemSummary"
strKeyName      = "Name"
strAssetTag     = WScript.Arguments(1)

'*** WQL Query to retrieve instances of Dell_SystemSummary
strWQLQuery = "SELECT * FROM " & strClassName & " WHERE " & _
  strKeyName & "=" & Chr(34) & strComputerName & Chr(34)

'*** Retrieve instances of Dell_Configuration class (there should only be 1 instance).
Set colInstances = GetObject("WinMgmts:{impersonationLevel=impersonate}//" & _
  strComputerName & "/" & strNameSpace).ExecQuery(strWQLQuery, "WQL", NULL)

'*** Use only first instance to set asset tag
For Each objInstance in colInstances
  '*** Set the new value for the property and save the instance
  objInstance.Properties_.Item("AssetTag").Value = strAssetTag
  objInstance.Put_
  Exit For
Next

Set colInstances = Nothing

'*** If any errors occurred, let the user know
If Err.Number <> 0 Then
  WScript.Echo "Setting the BIOS Asset Tag failed. Err:" & err.number
End If

WScript.Quit(Err.Number)

'*** Sub used to display the correct usage of the script
Sub Usage()
  Dim strMessage
  strMessage = "incorrect syntax. You should run: " & vbCRLF & _
    "cscript.exe //nologo DellSetAssetTag.vbs "
  WScript.Echo strMessage
End Sub

Download:  Set Asset Tag

Tags:

Computers are magnificent tools for the realization of our dreams, but no machine can replace the human spark of spirit, compassion, love, and understanding.
-Louis Gerstner

Inspired by Nina