Need VB Script to Move Computer to AD Container based on User CN
Posted on 2006-05-26
We are about to do a large rollout of new computers and in order to help automate things I'm trying to write a script that will automatically put the computer into the right container after it has joined the domain based on the currently logged in user's ID.
A typical user CN looks like this:
cn=userid, OU=USERS,OU=IT, OU=NY,DC=domain,DC=com
cn=userid2, OU=USERS,OU=HR, OU=LA, DC=domain,DC=com
There is a corresponding CN for computers that would look like this:
cn=computer, OU=COMPUTERS, OU=IT, OU=NY,DC=domain,DC=com
cn=computer2, OU=COMPUTERS, OU=HR, OU=LA,DC=domain,DC=com
Basically I'm looking for a script that would move the current hostname into the right container based on the cn of the currently logged in user. The only difference is the OU at the end (USERS vs COMPUTERS).
I know the solution will involve the MoveHere command to some extent along the lines of something like the below.
Set objNewOU = GetObject("LDAP://" & strDestinationOU)
Set objMoveComputer = objNewOU.MoveHere _
("LDAP://" & strComputer & strSourceOU, strComputer)
I'll need a full working vbs script.... Thanks in advance.