Home > Batch Scripting, Enteo, Scripting, Windows Server > How do you move a computer automatically from one OU to another using a script?

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.

  1. December 21, 2009 at 7:36 am

    Great site. Great information. Thank you

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: