Moving multiple computers from one OU to another

I'm a total AD weakling and I'm looking for some help on a powershell script.

The script should take each of the actual "computers" in the default OU - Computer --- and move them to another we can call otherOU.

Here's my bunk psuedocode for this one.


Computers = pathToDefaultComputerOU
otherOU = pathToTheOtherOU

Foreach comp in Computers
move comp to otherOU


So after a little reading from a book my boss gave me on learn powershell on your lunch break, I've done to refine my question.

I need to move all the computer objects from the default Computer OU into another OU w/i the same domain.

The script is going to become a cron job (sorry Linux admin here stuck in Windows world for a minute)

Hi, I am still learning Powershell, so I am not sure if this is the best way to do it, but it has worked in my test lab. :)

Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=yourdomain,DC=com" | ForEach-Object { Move-ADobject -Identity $_ -TargetPath "OU=newou,DC=yourdomain,DC=com" }

This will get all the Computer objects from the default computers container and move them to the targetpath OU.

If you want to change the default computers container you should first create an OU where you want to store your computers and the run this command:

redircmp ou=newcomputerou,dc=domainname,dc=com

I hope that this will help you. :)

Hi,
stumbled on this topic, could I suggest this GUI app to move multiple computers in AD from one OU to another?
youtube video