I have successfully deployed my first scripted install with drivers and everything! I am now looking to do an install that will automate computer names. Here is our scenario:

We have about 50 computers coming in for a refresh and I need to streamline this as much as possible for the helpdesk guys. I need the script to rename the computers sequentially without having to do it by hand. Is there anyway to do this? For example, we have in AD in a certain OU, workstations named like so: wrk1234, wrk1233 etc. I need the script to somehow either by manual input or by reading the AD envirnonment (ambitious i know) to start the computer names sequentially so we dont have to do it each time manually, I would THEN like it to join it to the domain as that computer.


Any tips?


I am also looking to automate software installs as well.

0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



I can explain to you my setup to see if that works for you.


I use the Get/Set computername.exe program.  This program prompts for a computer name as soon as an installation takes place.  The program then applies the name after windows installs.   Heres a sample of mine and Here - https://www.kace.com/support/resources/kb/article/Get-Set-ComputerName is the a nice article on how to use it.  


I then use a vbs to add it to the domain.  I can't see an attach option so I'll copy and pase the VBS.

Copy the contents after the ***


Const JOIN_DOMAIN             = 1

Const ACCT_CREATE             = 2

Const ACCT_DELETE             = 4

Const WIN9X_UPGRADE           = 16


Const JOIN_UNSECURE           = 64


Const DEFERRED_SPN_SET        = 256

Const INSTALL_INVOCATION      = 262144


If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then



  strDomain   = WScript.Arguments.Item(0)

  strUser = WScript.Arguments.Item(1)

  strPassword = WScript.Arguments.Item(2)


'set DNS IP address

  If WScript.Arguments.Count = 4 Then

    strDNSIP = WScript.Arguments.Item(3)

    Set objShell = CreateObject("WScript.shell")

    objShell.Run "netsh int ip set dns  ""local area connection"" static "& _

                  strDNSIP &" primary",0,0

  End If


End If



Set objNetwork = CreateObject("WScript.Network")

strComputer = objNetwork.ComputerName


Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _

                             strComputer & _

                             "\root\cimv2:Win32_ComputerSystem.Name='" _

                             & strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _

                                                strPassword, _

                                                strDomain & "\" & strUser, _

                                                NULL, _





I run the vbs as a Post install and the command line goes:

cscript Join_Domain.vbs "Domain.com" "USER" "PASSWORD"

 You will need an AD admin account to join to the domain, in our setup we created a general account to add PCs to the domain.  All the computers will be placed to the Computers OU, we then move it to the proper OU.  


This might not be the best solution, however this works for us as we name our computers based on our company inventory numbers.  

Answered 12/17/2013 by: RaulC08
White Belt

  • That is fine, but I have very specific computer naming schemes here. For example, I name the computers like WRK1234, WRK1233 etc. Lets say I have computer all the way up to WRK1234 and then I go into AD and create 50 computers from WRK1235 - WRK1284. I want to tell the script: "Hey use computer names WRK1235 - WRK1284 and place them into the correct OU"

    Is there any way to do that?
Please log in to comment