script to join a computer to a domain

Hello, im wanting a script to join a computer to a domain. I have a lot of machines that have been sysprep'd and i would like a way to automate joining a domian.

I know its possible within the sysprep.inf file but its not secure because sysprep.inf is not securly deleted (can be retrieved along with the passwords).  From the documentation i read, it says this is possible throught WMI but im not too sure on how to do this and whether this would be the best method. Any help or advice welcome?
Who is Participating?
resolver1Author Commented:
What are the parameters? How do I pass the parameters to the VBS file?  Ive created a few programs before but not VB Script, usually the paremeters are on the sub or Function line?
itsmeinConnect With a Mentor Commented:
see code snippet for usage details
Usage: cscript.exe NetDomOU.vbs Join|Unjoin|Remove /Domain:domain [/OU:ou] [/User:user] [/Password:password]
Join: Joins the computer to a domain.
Unjoin: Unjoin the computer from a domain. No other arguments required. The domain computer account will not be deleted!
Remove: Unjoin the computer from a domain and delete the domain computer account. No other arguments required. Administrative permissions on the domain are required! (The /user-argument is ignored). Wait for replication to finish before rejoining the computer!
/Domain: Name of the domain.
/User: The usersaccount used to execute the command, using the domain\username or username@domain notation! Leave username and password empty to use callers credentials.
/OU: The full 'distinguished name' of the organisational unit where the new domain computer account will be created when joining a domain. Example /OU:"OU=myOU, DC=domain, DC=com". The name must be between quotes! Leave empty to add the computer to the default 'Computers'-container. 
/Reboot: Reboot the computer if Join/Unjoin/Remove whas succesfull.

Open in new window

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

resolver1Author Commented:
cheers, i'll give it a go tomorrow. thanks
resolver1Author Commented:
thanks, works a treat!
resolver1Author Commented:
cheers mate, you've helped out a lot here.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.