Page 1 of 1 1
Topic Options
#181467 - 2007-10-10 10:34 PM Move a user from one OU to another in AD ?
Gerald_G Offline
Fresh Scripter

Registered: 2005-04-11
Posts: 34
Loc: Canada
I am wondering if anyone has written KIX code to move a user from one OU to another in AD.

I have searched and found this link to a script that moves a computer.
I believe from this I may be able to figure out moving a person, but any insight would be appreciated.

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun06/hey0623.mspx

Top
#181468 - 2007-10-10 10:46 PM Re: Move a user from one OU to another in AD ? [Re: Gerald_G]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Maybe by changing
WHERE objectCategory='computer'
to
WHERE objectCategory='user'

Top
#181470 - 2007-10-10 11:19 PM Re: Move a user from one OU to another in AD ? [Re: Gerald_G]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Curious why you would need to script it. Pretty easy to use the GUI

Don't get me wrong. I love scripting, but that doesn't mean I have to script everything. If the GUI can do it for me just as fast or easier then I use it, if it can't then I script it or use other tools as needed.

Top
#181474 - 2007-10-11 01:30 AM Re: Move a user from one OU to another in AD ? [Re: NTDOC]
Gerald_G Offline
Fresh Scripter

Registered: 2005-04-11
Posts: 34
Loc: Canada
Well the reason is - that I will be processing in batch a couple of thousand users, and some who fail to meet spcifications will be moved to another OU as part of a larger script.

The other option does include sorting on the extended attributes in AD, and moving after the fact with the interface.

Top
#181476 - 2007-10-11 01:56 AM Re: Move a user from one OU to another in AD ? [Re: Gerald_G]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Okay so did Witto's suggestion work out for you?
Top
#181479 - 2007-10-11 08:34 AM Re: Move a user from one OU to another in AD ? [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I Posted this earlier in the COM scripting department under "ADSI Computer Account Essentials"

 Code:
$ldap = GetObject("LDAP://OU=SomeSubOU,OU=SomeOU,DC=SomeDomain,DC=SomeDomainExtention")
$ = $ldap.MoveHere("LDAP://CN=TestPC2,OU=SomeNEWOU,OU=SomeOU,DC=SomeDomain,DC=SomeDomainExtention","CN=TestPC2")

Top
#181567 - 2007-10-12 06:36 PM Re: Move a user from one OU to another in AD ? [Re: Arend_]
Gerald_G Offline
Fresh Scripter

Registered: 2005-04-11
Posts: 34
Loc: Canada
Hey Kix people - thanks for the great responses.

I found in my case I could accomplish my goals easily within the AD MMC.

1: In the search tool, add the custom attribute 1 to my columns.
2: "Find Now" all users.
3: Sort by custom attribute column.

since in my case the goal was to move everyone without data in this field to another OU....

4: Select all accounts without data in the field.
5: Right Click - select Move, select new OU

- Tada !

But thanks to Kix for getting the data into the extension attribute in the first place.

Thanks Again
Gerald

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1362 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.063 seconds in which 0.031 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org