Script to remove old computer name from AD
Hey guys and gurls,
We currently use FOG to image our machines with a Windows 7 Syspreped image on a windows domain on a windows server 2008 R2 dc.
I have written scripts to install drivers, check for updates, add to active directory,etc so the build can be deployed without user interaction :)
However, I would like to add a feature into this that will remove the computer with the same name on the domain. As we sometimes have to reimage a computer(s) that are already on domain, I would like a script that if it fails to add to domain using my scripts puts a txt file with the name of the PC itself onto a share/server. Then this server which is on the domain checks with a script every 5-15mins and if it sees a txt file gets its/there names and searches AD and removes the computers in question. Then the new computer will wait 5-15 mins and the run the task again, therefore it should be able to add itself to domain.
I can do the new computer side of scripts but need help getting a script on the server to check for the text file and then remove the associated computer from domain based on this information.
I thought there might be a way of on the new computer as to over rule the existing computer object.
Thanks in advance for your guys help,