[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 635
  • Last Modified:

Rename multiple computers with a VBScript

I need to rename about 1500 computers on my domain. We are changing our desktop / laptop naming convention. The new naming convention will be Site Code - Serial number. I want to put the User Name - Computer Model - Asset Tag. I know I can get the Serial number from WMI, the rest of the info I will supply from a text file. I have seen several Computer Renaming VBScript, but it's been a long time since i've written a script. I could really use some assistance.
  • 2
1 Solution
Jared LukerCommented:
The renaming of a computer is pretty straight forward....

This script should change the name locally and in AD.  You can add to it anyway you wish in order for it to do what you want it to.

Here is the code to do it..

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("WebServer")

Open in new window

Jared LukerCommented:
This will still involve someone with the local and AD rights to touch and log into the computer, but the script can make it much less painful.
Can you please post a sample line from the text file that will be read?

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now