Hoe to move a bunch of systems into an OU at once

I need to move about 100 system to a particular OU in AD. How can I do all at once?
rdefinoAsked:
Who is Participating?
 
becraigConnect With a Mentor Commented:
if you have a list of computers you can use powershell

import-module ac*
gc c:\serverlist.txt | % {
Get-ADComputer $_| Move-ADObject -TargetPath "ou=something,dc=mydomain,dc=com"
}

Open in new window

0
 
rdefinoAuthor Commented:
Do I enter the commands line by line like you have them?
0
 
rdefinoAuthor Commented:
Also how server list be formatted?
0
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

 
becraigCommented:
you can(from a powershell window) or you can save it as a powershell script

script.ps1 and run it from a powershell window as script.ps1

Server list will be one server name per line...
E.g

SERVER1
SERVER2
SERVER3
0
 
rdefinoAuthor Commented:
if the ou you is buried down say 3 levels like:

machines-win7-systems

Do show it in the script like that?

ou=machines,ou=win7,ou=systems
0
 
becraigCommented:
You can use simple AD command to find the correct OU

dsquery computer -name <computername>

The output from this would show you the OU (minus the computer name portion)
0
 
rdefinoAuthor Commented:
Actually the OU I'm moving them to is buried 3 levels down. Wasn't sure how to show that in the script.

Looks like i only need a target OU, not the source...correct?
0
 
becraigCommented:
Yup you only need the target, so my suggestion was to simply query a computer already in the target OU to get the correct value.
0
 
rdefinoAuthor Commented:
Great work!!
0
All Courses

From novice to tech pro — start learning today.