Note: This article was originally published in 2006. Some steps, commands, or software versions may have changed. Check the current General documentation for the latest information.
I personally prefer to use the solution provided by Berkeley found at http://calnetad.berkeley.edu/documentation/scripts/. I went ahead and downloaded the (http://calnetad.berkeley.edu/documentation/scripts/#joindomain) script and made slight changes to it. I also got the latest netdom.exe from the support tools from the Windows 2003 R2 CD. I might add the zip file in the future just in case they take it offline, but I think this is a good resource nevertheless.
Summary
You’ve successfully learned add computers to a domain via scripting. If you run into any issues, double-check the prerequisites and ensure your General environment is properly configured.