Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Rename Dell Machine By Service Tag
 

Vbscript / Operating System / Rename Dell Machine By Service Tag

The following code will read the service tag from a Dell machine and rename the machine using the service tag. This allows a correlation between the physical asset tag and the machine name in AD and simplifies the management process.


Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
strSTag = objSMBIOS.SerialNumber
Next

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

Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
err = objComputer.Rename(strSTag)
Next

strPCName = "PC" & strSTag

Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
intErr = objComputer.Rename(strPCName)
Next





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
          - Add Remove Windows Server 2003 Components
          - Add Remove Windows Vista Components
          - Add Remove Windows Xp Components
          - Autologon And Runonce
          - Change Display Resolution
          - Change Location I386 Setup Files
          - Change Offline Folder Cache Location
          - Dell Bios Set Boot Device Order
          - Dell Bios Set Configuration Settings
          - Dell Bios View Configuration Settings
          - Dell Bios View Device Boot Order
          - Disable Vista User Account Control
          - Enumerate Cd Drives
          - Enumerate Computer Drives
          - Enumerate Disk Volumes
          - Enumerate Registry Keys
          - Flush Remote Dns Cache
          - Get Machine Hardware Model
          - Read Registry Key
          - Rename Computer
          - Rename Dell Machine By Service Tag
          - Set Internet Explorer Homepage
          - Set Random Desktop Wallpaper On Startup
          - Start And Stop A Service
          - Windows Login Timer
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers