Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automatically move computers into a certain OU (Server 2008)

Posted on 2013-06-26
12
Medium Priority
?
1,070 Views
Last Modified: 2013-07-09
What I'd like to achieve is this:
 
When a computer is joined to the domain and the computer name starts w/ "CR" that it be moved to the "Student Computers" OU.

I don't want to pre-stage. I'm running 2008 (R2) domain functional level is 2003.

Thanks!!
0
Comment
Question by:PapaSmurff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
12 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 39279043
You can have all machines go to a certain OU using redircmp   http://technet.microsoft.com/en-us/library/cc770619(v=ws.10).aspx

There is no way to have them intelligently placed in an OU based on name.  You would have to script a computer join process to do something like that.

Thanks

Mike
0
 
LVL 56

Expert Comment

by:McKnife
ID: 39279919
...but of course you could setup a scheduled task at the DC that regularly moves any object based on name to your target OU using the dsmove command.
Although powershell rules, this is batch:

for /f %%a in ('dsquery computer "OU=SourceOU,DC=yourdomain,DC=localOrWhatever" -name CR*') do dsmove %%a -newparent ou=targetOU,DC=yourdomain,DC=localOrWhatever

Open in new window


This would solve it.
0
 

Author Comment

by:PapaSmurff
ID: 39293740
Great. Thanks McKnife! Sorry for the delayed response just got back to work.
 
How would that look in task scheduler? Advanced task and browse to that as a .bat file??
Thanks.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 56

Expert Comment

by:McKnife
ID: 39294037
Exactly. Execute as System, passw. left empty.
0
 

Author Comment

by:PapaSmurff
ID: 39294129
Ok, it didn't work but I'm horrible at scripting. This is what's in the bat file.

for /f %%a in ('dsquery computer "OU=Computers,DC=hcrhs,DC=k12,DC=nj,DC=us," -name CR*') do dsmove %%a -newparent ou=WorkStations, ou=Student Computers,DC=hcrhs,DC=k12,DC=nj,DC=us

Our domain is hcrhs.k12.nj.us. Joined computers go into the Computers OU and I'd like them to go to:
Workstations -> "Student Computers" OU

What did I mess up in the script?
Thanks again!
0
 
LVL 57

Expert Comment

by:Mike Kline
ID: 39294181
Is that the Computers OU or the default computers containers your computers start in?

if it is the default container user

CN=Computers.....

instead of OU=Computers

Thanks

Mike
0
 

Author Comment

by:PapaSmurff
ID: 39294222
Yes, it is. I changed that to CN=
Didn't move the test computer. The rest of the script look ok?
Thanks,
Ron
0
 
LVL 56

Expert Comment

by:McKnife
ID: 39294317
I am about to setup a new vm testlab with 2012 R2 preview right now and won't be able to test and help you before in a few hours. But I will :)
0
 
LVL 56

Expert Comment

by:McKnife
ID: 39294964
Hi.

Should be
for /f %%a in ('dsquery computer "CN=Computers,DC=hcrhs,DC=k12,DC=nj,DC=us," -name CR*') do dsmove %%a -newparent ou="student computers",ou=workstations,DC=hcrhs,DC=k12,DC=nj,DC=us

Open in new window

0
 

Author Comment

by:PapaSmurff
ID: 39296257
Thanks McKnife. Still didn't work. How can I pause the .bat file to see if there are any error messages?
0
 
LVL 56

Accepted Solution

by:
McKnife earned 2000 total points
ID: 39299295
Add a second line: pause

PS: Aargh. There was an additional "," that did not belong there... try
for /f %%a in ('dsquery computer "CN=Computers,DC=hcrhs,DC=k12,DC=nj,DC=us" -name CR*') do dsmove %%a -newparent ou="student computers",ou=workstations,DC=hcrhs,DC=k12,DC=nj,DC=us

Open in new window

0
 

Author Closing Comment

by:PapaSmurff
ID: 39310981
McKnife you da man!!! Thanks! Worked like a charm!
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question