Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 108
  • Last Modified:

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?
0
rdefino
Asked:
rdefino
  • 5
  • 4
1 Solution
 
becraigCommented:
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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now