O'Reilly logo

Active Directory Cookbook by Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.5. Renaming a Computer

Problem

You want to rename a computer.

Solution

Using a graphical user interface

  1. Log on to the compute r either directly or with a remote console application, such as Terminal Services.

  2. Open the Control Panel and double-click on the System Applet.

  3. Select the Computer Name tab and click the Change button.

  4. Under Computer Name, type the new name of the computer and click OK until you are out of the System applet.

  5. Reboot the machine.

Using a command-line interface

> netdom renamecomputer <ComputerName> /NewName <NewComputerName> /UserD[RETURN]
<DomainUserUPN> /PasswordD * /UserO <ComputerAdminUser> /PasswordO * /Reboot

Using VBScript

' This code renames a computer in AD and on the host itself.
' ------ SCRIPT CONFIGURATION ------
strComputer     = "<ComputerName>"       e.g. joe-xp
strNewComputer  = "<NewComputerName>"    e.g. joe-pc
strDomainUser   = "<DomainUserUPN>"      e.g. administrator@rallencorp.com
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser    = "<ComputerAdminUser>"  e.g. joe-xp\administrator
strLocalPasswd  = "<ComputerAdminPasswd>" ' ------ END CONFIGURATION --------- '########################### ' Connect to Computer '########################### set objWMILocator = CreateObject("WbemScripting.SWbemLocator") objWMILocator.Security_.AuthenticationLevel = 6 set objWMIComputer = objWMILocator.ConnectServer(strComputer, _ "root\cimv2", _ strLocalUser, _ strLocalPasswd) set objWMIComputerSystem = objWMIComputer.Get( _ "Win32_ComputerSystem.Name='" & _ strComputer & "'") '########################### ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required