CMD – Rename Local Computer, Join Domain, Join Specific OU

command linedomainrenamewmic

Alright so not sure if this is entirely possible all in one.

Situation: Brand new computer not on the domain, just a local workgroup. Want to change that computers name, join a domain, and put the computer name in a specific workgroup for that domain. This can all be done via the GUI all at once so it should be hypothetically possible via command line right?

I can rename a local computer using this method:
CMD > WMIC COMPUTERSYSTEM where "Name='%computername%'" CALL Rename NEWNAME, Password, User

This works however it requires a restart for the changes to happen.

Next I made a batch file that works great to do what I want using NETDOM, however it can't be used until that computer is restarted due to the name change…

SET /P compname=[promptString]
SET /P org=[promptString]

NETDOM JOIN %compname% /Domain:DOMAIN.NET /OU:%org%,DC=DOMAIN,DC=net /UserD:DOMAIN\user /PasswordD:password /Reboot:15 /verbose
PAUSE

So I guess my question is… is there any way to do this in one way without having to restart? If a restart is absolutely required its too much time consumption; the only reason I want to do this VS using the windows GUI is to get it in the OU I want right away without having to pre-stage or go into AD and move the computer.

Best Answer

A restart is a must to reflect the changes. Even when you do these things without using cmd, it prompts you to restart your machine. So, its must really be the only way to go about it.

Related Question