Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


November 03, 2003

Rem: Moving Users Between OUs


RSS
View this exclusive article with VIP access -- click here to join |
See More Active Directory (AD) Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

I'm creating a script that moves users from one Active Directory (AD) organizational unit (OU) to another AD OU according to data in a comma-separated value (CSV) input file. As Figure 1 shows, each line of the input file contains two fields: the user's common name (cn) and computer type (Desktop or Laptop). I'm using the computer type to control the OU that each user moves to. For example, I'm moving users with desktop computers from the ou=corp,dc=MyDomain,dc=com OU to the ou=Desktops,dc=MyDomain,dc=com OU and users with laptop computers from the ou=corp,dc=MyDomain,dc=com OU to the ou=Laptops,dc=MyDomain,dc=com OU. I've had success opening the input file and creating a log file. My dilemma is parsing the data and performing the move operation. Can you point me in the right direction?

You bet—Listing 1, page 10, is a reworked version of the UserMove.vbs script you sent me. Let's walk through the script, which should help you identify where you took a wrong turn. . . .

Reader Comments
I am doing something similiar with an excel spread sheet using the movehere method but my script always fails on line 11 when i try and insert the argument from my spread sheet. My goal is to use data parsed from active directory with Hyena to rename user objects within an OU I have sucessfully used this script to modify mutiple attributes of about 650 users in our domain. It seems that the objou.move here method doesn't allow me to insert an argument.

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\moveuser.xls")
intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""


Set objUser = GetObject("LDAP://us0-dc01/" & objExcel.Cells(intRow, 1).Value)
objOU.MoveHere("LDAP://us0-dc01/", & objExcel.Cells(intRow, 2).Value) , ("cn=", & objExcel.Cells(intRow, 3).Value)












intRow = intRow + 1


Loop

objExcel.Quit


Connollyr12 September 01, 2004 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...


Active Directory (AD) Whitepapers Sustainable Compliance: How to reconnect compliance, security and business goals

Managing Unix/Linux with Microsoft System Center Operations Manager 2007 Cross Platform Extensions Beta

Addressing the Insider Threat with NetIQ Security and Administration Solutions

Related Events Concrete Ways to Make Sure Your SharePoint Deployment Doesn't Blow Up

PCI Requirements for Windows and Active Directory: Straight from a Certified Auditor

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

Keeping Your Business Safe from Attack: Monitoring and Managing Your Network Security

Windows 2003: Active Directory Administration Essentials

Related Active Directory (AD) Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing