[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to move the user accounts from one OU to another OU by VBScript?

Posted on 2008-06-18
2
Medium Priority
?
1,249 Views
Last Modified: 2008-06-19
Dear all experts,

I would like to implement a VBScript program which is used to move some user / computer accounts from one OU to another, please kindly give me some advise about it.

Regards,
0
Comment
Question by:towo2002
[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
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 1000 total points
ID: 21819063
Hi, this article should definately get you started.  If you need anything else, let us know:

How Can I Move a Computer From an Unknown OU into a Known OU?
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/hey0623.mspx

Where it's got
"AND Name='atl-ws-01'"

you could change that to
"AND Name='" & strComputerName & "'"

and at the top of the script have
strComputerName = InputBox("Enter the name of a computer to move:", "Computer Name")

Regards,

Rob.
On Error Resume Next
 
Const ADS_SCOPE_SUBTREE = 2
 
objOU = GetObject("LDAP://ou=Finance,dc=fabrikam,dc=com")
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
 
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='computer' " & _
        "AND Name='atl-ws-01'"
Set objRecordSet = objCommand.Execute
 
objRecordSet.MoveFirst
 
Do Until objRecordSet.EOF
    strADsPath = objRecordSet.Fields("ADsPath").Value
    objOU.MoveHere strADsPath, vbNullString
    objRecordSet.MoveNext
Loop

Open in new window

0
 
LVL 15

Expert Comment

by:markpalinux
ID: 21821199


When I have that type of task I like to use dsmove - I just find it cleaner, I run csvde or dumps with vbscript before and after to check that all went well.

dsmove, dsquery, dsadd, etc all part of Windows 2003.


the script center at Microsoft website gives a very basic vbscript for move user:
http://www.microsoft.com/technet/scriptcenter/scripts/ad/users/manage/default.mspx
Set objOU = GetObject("LDAP://ou=sales,dc=na,dc=fabrikam,dc=com")

objOU.MoveHere _
    "LDAP://cn=BarrAdam,OU=hr,dc=na,dc=fabrikam,dc=com", vbNullString

Mark
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

656 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