Solved

Script to rename a member server for Windows Server 2008 R2

Posted on 2010-08-23
3
561 Views
Last Modified: 2012-08-14
I have a server that's a part of a workgroup.  I need to join it to a domain and rename it.  Preferably, both would happen at the same time.  The script I was using was:  

REM Asks for computer name and domain name
SET /P BRANCH_NO="Enter branch number: "
SET /P DOMAINNAME="Enter domain name: "
SET /P USERNAME="Enter domain username: "
SET /P PASSWORD="Enter password: "

REM Joins server to the domain
netdom join /d:%DOMAINNAME% localhost /ud:%DOMAINNAME%\%USERNAME% /pd:%PASSWORD%  /force >> c:\domain.txt

REM Renames server to isb-brXXXfs
netdom renamecomputer localhost /newname:isb-br%BRANCH_NO%fs /userd:administrator >> c:\domain.txt

The first part joins the domain but the command requires someone to enter Y or N.  I tried /force but that doesn't work.  Also tried putting a Y in at the end of the domain command but then I get an error.  Any suggestions?
0
Comment
Question by:sedberg1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:sedberg1
ID: 33505403
Okay, so I have the script.  



REM Asks for computer name and domain name
SET /P BRANCH_NO="Enter branch number: "
SET /P DOMAINNAME="Enter domain name including TLD: "
SET /P USERNAME="Enter domain username in format domain\administrator: "
SET /P PASSWORD="Enter password: "

REM Joins server to the domain
netdom join localhost /Domain:%DOMAINNAME% /UserD:%USERNAME% /PasswordD:%PASSWORD% >> c:\domain.txt

REM Renames server to isb-brXXXfs
netdom renamecomputer localhost /NewName:isb-br%BRANCH_NO%fs /UserD:%USERNAME% /PasswordD:%PASSWORD% /force >> c:\domain.txt

REM Reboots the server to make the changes permanent.
shutdown -r -t 05 -c "System rebooting in 5 seconds"



But the problem is that whenever I run the second part of the script, I get the following error.  This is because obviously the computer account in AD already exists.  How can I run this script so it overwrites the existing computer account?  The thing is, this script will be run during a multi-server deployment, and the names will be created in AD already for later easier management.

The account already exists.
The command failed to complete successfully.

0
 
LVL 35

Accepted Solution

by:
Joseph Daly earned 500 total points
ID: 33505982
I would think that as long as you reset the computer account in active directory before attempting to join the computer to the domain you should be ok. Something along the lines of

dsquery computer -samid {computername} | dsmod computer -reset

This should reset the computer account and allow you to join it to the domain without the error above.
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 33521615
Thanks for the accept. Did this work correctly for you?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question