PC Review


Reply
Thread Tools Rate Thread

Active Directory Scripts to move Computers

 
 
stefanoc
Guest
Posts: n/a
 
      16th Nov 2004
I am trying to find a script that will move computers from the default
computers container, into an OU based on their location fields.

Example:

Location = Human Resources - Move to OU Human Resources

Has anyone got a script that can do this, or that can point me in the
right direction.
 
Reply With Quote
 
 
 
 
Ed Siff
Guest
Posts: n/a
 
      16th Nov 2004
It's likely going to require VB. Search google groups for: script move OU,
you'll find plenty there.

Ed

In article <(E-Mail Removed)>,
(E-Mail Removed) (stefanoc) wrote:
>I am trying to find a script that will move computers from the default
>computers container, into an OU based on their location fields.
>
>Example:
>
>Location = Human Resources - Move to OU Human Resources
>
>Has anyone got a script that can do this, or that can point me in the
>right direction.

 
Reply With Quote
 
Jerold Schulman
Guest
Posts: n/a
 
      17th Nov 2004
On 16 Nov 2004 08:49:58 -0800, (E-Mail Removed) (stefanoc) wrote:

>I am trying to find a script that will move computers from the default
>computers container, into an OU based on their location fields.
>
>Example:
>
>Location = Human Resources - Move to OU Human Resources
>
>Has anyone got a script that can do this, or that can point me in the
>right direction.



See tips 7382 and 7992 and links in the 'Tips & Tricks' at http://www.jsiinc.com

@echo off
setlocal ENABLEDELAYEDEXPANSION
set qry=dsquery * domainroot -filter "(&(objectCategory=Computer)(objectClass=Computer))" -attr distinguishedName location -L -LIMIT 0
for /f "Tokens=1*" %%a in ('%qry%') do (
if /i "%%a" EQU "distinguishedName:" set DN=%%b
if /i "%%a" EQU "location:" if /i "%%b" EQU "Human Resources" DSMOVE !DN! -newparent xxxxxxxxx
)
endlocal



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Reply With Quote
 
Al Dunbar [MS-MVP]
Guest
Posts: n/a
 
      21st Nov 2004

"Ed Siff" <(E-Mail Removed)> wrote in message
news:419a58e5$(E-Mail Removed)...
> It's likely going to require VB. Search google groups for: script move

OU,
> you'll find plenty there.


Not to pick nits, but I doubt that one would require VB - VBScript by itself
would probably suffice.

Of course, the specific application might have some unforeseen ambiguities.
OU names (i.e. RDN or canonical name) need not be unique across AD. The
script might need to make some choices between the "Human Resources" OU
found in the "Management" OU, and the "Administrative" OU, for example.

The question I would ask the OP is: how did the computer accounts come to
have their location attributes set? If this was input by a user or operator,
is there a chance of a spelling error, and how would this be handled by your
script?

If the location attribute setting is at least partly automated, then perhaps
that process could be amended to also adjust the OU. One possibility could
be to present to the person setting up the workstation a drop-down list of
all possible OU's and have them pick the correct one.


/Al


> Ed
>
> In article <(E-Mail Removed)>,
> (E-Mail Removed) (stefanoc) wrote:
> >I am trying to find a script that will move computers from the default
> >computers container, into an OU based on their location fields.
> >
> >Example:
> >
> >Location = Human Resources - Move to OU Human Resources
> >
> >Has anyone got a script that can do this, or that can point me in the
> >right direction.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory scripts WDSnews Microsoft Access 1 1st Oct 2009 01:22 PM
Active Directory scripts Ricky Microsoft Windows 2000 Active Directory 4 29th Oct 2007 02:08 AM
Active Directory scripts Ricky Microsoft Windows 2000 CMD Promt 4 29th Oct 2007 02:08 AM
Active Directory scripts Ricky Microsoft Windows 2000 Group Policy 4 29th Oct 2007 02:08 AM
Multiple Active Directory Logon Scripts???? C.P. Microsoft Windows 2000 Active Directory 2 21st Jul 2004 08:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.