Question

Locked

How to correct computer accounts on a domain after renaming locally?

By gmorris ·
On our new Microsoft network of 1400 Computers we are joining all computers to the domain.
We found out that many of the computers have the same name.
So, to correct this, we made an automatic renaming scheme using the utility compname.
Well, compname does not rename the computer on the domain controller.
We now realize using compname only complicated things.
Now here is our problem:
Many computer names do not match names in active directory.
When we try to use command line netdom to remove and readd them, we get an access denied error because it cannot find the computer name in active directory.
We can do this with no problem the manual way by going into system properties.
But this is entirely too time consuming.
As of now, most computers are still logging into the domain.
But I know this is going to bit us in the butt later, especially when we try to push out apps to all the workstations.
I'm attempting to write a logon script that will do a dsquery to check the local computer name against what is in active directory, and if it does not find a matching computer name it automatically removes the computer from the domain and rejoins it.
As I stated above, the only problem is, this script fails to remove the computer from active directory.
I'm no expert at scripting, but Here it is:

for /F "tokens=1 delims=" %%g in ('dsquery computer domainroot -name %computername%') do (
set this=%%g
set okay=yup
)
if '%okay%'=='yup' set this1="%this%-"
if '%okay%'=='yup' set this2=%this1:~2,2%
if NOT '%okay%'=='yup' set this2="-"
if NOT %this2%==CN (
netdom remove /d:peru.k12.in.us %computername% /ud:peru.k12.in.us\Administrator /pd:Revelation@1714
netdom join %computername% /domain:peru.k12.in.us /UserD:Peru\Administrator /PasswordD:Revelation@1714
)

Some of those variables were because it errored out from the UNDEFINED variables comparisons. So I had to make sure there was no UNDEFINED variables.
Any help is appreciated.
Thanks

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Desktop Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums