16.17. Creating a Computer Account


You want to create a computer account.


Using a graphical user interface

  1. From the Administrative Tools, open the Active Directory Users and Computers snap-in.

  2. If you need to change domains, right-click on Active Directory Users and Computers in the left pane, select Connect to Domain, enter the domain name and click OK.

  3. In the left pane, browse to the parent container for the computer, right-click on it, and select New Computer.

  4. Enter the name of the computer and click OK.

Using a command-line interface

Use the following command to create a computer account in Active Directory:

> dsadd computer "<ComputerDN>" -desc "<Description>"

Using VBScript

' This code creates a computer account in Active Directory.
strBase = "<ParentComputerDN>"  ' e.g., cn=Computers,dc=rallencorp,dc=com
strComp = "<ComputerName>"      ' e.g., joe-xp
strDescr = "<Description>"      ' e.g., Joe's Windows XP workstation
' ------ END CONFIGURATION ---------
set objCont = GetObject("LDAP://" & strBase)
set objComp = objCont.Create("computer", "cn=" & strComp)
objComp.Put "sAMAccountName", strComp & "$"
objComp.Put "description", strDesc
objComp.Put "userAccountControl", ADS_UF_WORKSTATION_TRUST_ACCOUNT
Wscript.Echo "Computer account for " & strComp & " created"


Creating a computer account in Active Directory is not much different from creating a user ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.