Link to home
Start Free TrialLog in
Avatar of shoris
shoris

asked on

Script (VBS or Batch)

I am in the process of a ADMT migration. I am migrating computers as is to the new domain. However, in the domain, I would like to run a batch file or script to rename the computer accounts to the new naming convention. In addition, I would like to include if possible from a file the old computer name and the new computer name. And return a result file whether the rename was successful or not so that I can troubleshoot the computers that didn't get renamed. Please advise.
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Have you considered using input file for computer migration? Then you can specify in that file the old name and new name. Nothing to do later :) After migration, your computers would have new name in the new domain

an example input file

SourceName,TargetName
oldName,newName


and ADMT syntax

admt computer /sd:aaa.com /td:bbb.com /tot:add /tff:yes /tlg:yes /tps:yes /trg:yes /tss:yes /tup:yes /tur:yes /rdl:2 /f:c:\include.txt

Open in new window


Regards,
Krzysztof
Avatar of shoris
shoris

ASKER

The problem with that is that, if it has to pick up a new name, it will need to dis-join from network first, then renamed, then rebooted then joined to the new name in the new domain.

That can be done all within the computer migration on the re-name without any issues?
Yes, it works during agent run. Of course reboot is required in this case as in standard computer rename process.

Just try with some test machine

Krzysztof
Avatar of shoris

ASKER

I have attached the ADMT tool example, then are you saying, in a text format, I can have my old machines and new machine name..Then would the ADMT reboot this machine 3 times to do the final rename in the new domain?

I thought, if I migrate them as is, then run a netdom scripted utility that would be faster and work, but I need a netdom script that would have an include file and give me the results as well.
Example.docx
yes, choose read object from input file. And there should be just 1 reboot as I remember.
I need to check that i my test environment as I'm not sure now :)

Krzysztof
Avatar of shoris

ASKER

Unfortunately, I won't be able to test until another 2 weeks :( so if you do it in yours that would be great.. You see.. I heard there is  only one reboot, but in a rename process, it requires two reboots so that's why I thought, if if I just migrate the machines as is with the naming convention and then do a netdom utility to do another rename.
Take it easy, there is no rush if you do not need it now :]
I will test that tomorrow morning and will let you know the results in short guide

Krzysztof
Avatar of shoris

ASKER

You are awesome :)... Thank you so much. Of course everyone wants these migrations done quickly and efficiently.
Avatar of shoris

ASKER

any news krzysztof..
Sorry, I had no chance to check that yet. I will do that as soon as possible and post an update.

Thank you in advance for understanding

Krzysztof
OK, I found some issues during migration computers over input file with computer name change :/ Looks like there is need to change computer names before migration :|
Let me test this deeply

Krzysztof
Avatar of shoris

ASKER

Yes, that's what I thought :(.. I was thinking if the computer name would be changed after migration with a netdom then that would work.

I'm just looking for the syntax to change a number of computers from an input file in a netdom command line.
ASKER CERTIFIED SOLUTION
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shoris

ASKER

Thank you so much.. I will try that for sure.
Avatar of shoris

ASKER

I have been trying to do this on a command line on the DC

 * -filter "(objectClass=computer)" -attr name -limit 0 | find /v "name" >>c:\comps.txt

changed to C:windows\system32 and ran that command and it came back as not an internal command..
Avatar of shoris

ASKER

this is what i get


C:\Users\Administrator>dsquery * -filter "(objectClass=computer)" -attr name -limit 0 | find /v "name" >>c:\comps.txt

C:\Users\Administrator>1:
The system cannot find the drive specified.

Wierldy when i open up the Text file I get all the computer names.
Avatar of shoris

ASKER

would this be the result in the text file ?

OldName,NewName
MSPC001,MXPC001
Yes sure. But if you use comma (,) as separator then you need to modify a little bit the syntax

for /f "tokens=1-2 delims=," %i in (c:\comps.txt) do netdom renamecomputer %i /NewName %j /UserD:DomainAdminAccount /PasswordD:ItsPassword /Force /REBoot:1

Open in new window


the difference is that delims is defined to not use default space as separator but comma

And I'm really surprised that you saw an error and whole output was in a text file :/ Really strange

Krzysztof
Avatar of shoris

ASKER

I really appreciate your help. Thank you so much.
You're welcome :)

I hope I could help

Krzysztof