JSI Tip 10553. How can I move all the Distinguished Names specified in a text file to a new OU (Organizational Unit)?


Using ADMod.exe freeware, I have scripted MoveOU.bat to move all the Distinguished Names that you specify in a file to a new, common, OU.

The syntax for using MoveOU.bat is:

MoveOU Filename "New OU"

Where:

FileName is the file that contain the quoted Distinguished Names, one per line, that you want to move to New OU.
         Example: "CN=TESTCOMP,CN=Computers,DC=JSIINC,DC=COM" 
                  "CN=TESTUSER,OU=West Coast,DC=JSIINC,DC=COM"
New OU   is the new OU that you want all the objects in FileName to be moved to, like "OU=East Coast,DC=JSIINC,DC=COM"
MoveOU.bat contains:
@echo off
if \{%2\}==\{\} @echo Syntax: MoveOU Filename NewOU&goto :EOF
if not exist %1 @echo MoveOU %1 does not exist.&goto :EOF
setlocal
set file=%1
set newou=%2
for /f "Tokens=*" %%a in ('type %file%') do (
 admod -b %%a -unsafe -move %newou%
)
endlocal



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish