Hi all,
Im trying to create a batch file/vbs or whatever script that allows me to
run these commands.
Objective of script:
To search the whole Active Directory for objects that are duplicated (search
condition $DUPLICATES*), mark them as disabled and move them to an OU.
If i put these following commands into command prompt one by one it works,
but not when i put it into .cmd or .bat (due to the for loop and the
variables)
for /F "usebackq delims=""" %i in (`dsquery * domainroot -filter
"(&(objectCategory=*)(objectClass=*) (sAMAccountName=$DUPLICATE*))"`) do
dsmod user %i -disabled yes
for /F "usebackq delims=""" %i in (`dsquery * domainroot -filter
"(&(objectCategory=*)(objectClass=*) (sAMAccountName=$DUPLICATE*))"`) do
dsmove %i -newparent ou=scheduled,dc=YOURDOMAIN,dc=com
if I use the default piping for dsquery and dsmod it works fine however if i
use dsquery piping with DSMOVE (if there are more than 1 objects to be
moved) it failed! (crap)
dsquery * domainroot -filter "(&(objectCategory=*)(objectClass=*)
(sAMAccountName=$DUPLICATE*))" | dsmod user -disabled yes
dsquery * domainroot -filter "(&(objectCategory=*)(objectClass=*)
(sAMAccountName=$DUPLICATE*))" | dsmove -newparent
ou=scheduled,dc=YOURDOMAIN,dc=com
Anyone kind enough to mod this? :)
Cheers!
Kind Regards,
Freddy Hartono