How do you move a computer automatically from one OU to another using a script?
I was asked the following question recently when finishing our Citrix server deployment method.
We needed a script that would run on a computer as part of a sequence of scripts that would move a server from its current OU to the servers final resting place a terminal servers OU.
The below script achieved what we needed by using the computers %computername% variable to move the computer.
In our case the following apply:
·The computers name is using the variable %computername%
·The domain is domain.net
·The computers OU before the move is computers
·The OU we wish to move to is Terminal Servers
dsmove “CN=%computername%,OU=computers,DC=domain,DC=net” -d domain.net -newparent OU=”Terminal Servers”,DC=domain,DC=net
if you are unaware of the computers current OU before the move and you still wish to script the move, the following forum post will get you in the right direction.