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

Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by name

name
Thu Sep 09 05:10:41 CDT 2004


Does your ng query take all words?

Or only those from the Ms dictionary.

=============================

I am afraid your sense of reality is confined to

insulated everyday monkey problems.

==============

"DUPLICATE"

Yep !

Your most profound word.

====








"Freddy Hartono" <freddy_hartono@removethis.non.agilent.com> wrote in
message news:%234uQx7hlEHA.3712@TK2MSFTNGP15.phx.gbl...
> 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
>
>


Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by craiglandis

craiglandis
Thu Sep 09 08:04:01 CDT 2004

The first thing that sticks out is that you need to use %%i for
variables in the FOR command in a batch file.

From "FOR /?"

"To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %i is different
from %I."

Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by Al

Al
Thu Sep 09 20:37:32 CDT 2004


"Freddy Hartono" <freddy_hartono@removethis.non.agilent.com> wrote in
message news:%234uQx7hlEHA.3712@TK2MSFTNGP15.phx.gbl...
> 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.

One caution: if your naming convention and practice is such that the
canonical names are not globally unique, your attempt to move a bunch of
accounts to a single OU might fail.

/Al


> 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
>
>



Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by Freddy

Freddy
Thu Sep 09 20:54:48 CDT 2004

Hi

Thanks for that!

just needed a %% instead of % (damn been spending useless hours trying to
find an alternative to ds commands)


"Craig" <craiglandis@hotmail.com> wrote in message
news:f03bab1c.0409090504.3fc54dc1@posting.google.com...
> The first thing that sticks out is that you need to use %%i for
> variables in the FOR command in a batch file.
>
> From "FOR /?"
>
> "To use the FOR command in a batch program, specify %%variable instead
> of %variable. Variable names are case sensitive, so %i is different
> from %I."



Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by Gary

Gary
Sun Sep 12 19:36:01 CDT 2004

What the hell is this supposed to mean?

"name" <nospam@user.com> wrote in message
news:ea7UFVllEHA.1356@TK2MSFTNGP09.phx.gbl...
>
> Does your ng query take all words?
>
> Or only those from the Ms dictionary.
>
> =============================
>
> I am afraid your sense of reality is confined to
>
> insulated everyday monkey problems.
>
> ==============
>
> "DUPLICATE"
>
> Yep !
>
> Your most profound word.
>
> ====
>
>
>
>
>
>
>
>
> "Freddy Hartono" <freddy_hartono@removethis.non.agilent.com> wrote in
> message news:%234uQx7hlEHA.3712@TK2MSFTNGP15.phx.gbl...
> > 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
> >
> >
>



Re: Scripting DSMOVE DSQUERY and DSMOD help! (EASY?) by Al

Al
Mon Sep 13 20:04:11 CDT 2004

Exactly what he seems to be saying. Specifically, nonsense. All his posts
are like that, and he does not respond to requests to clarify, because there
is nothing to clarify.

/Al

"Gary Morris" <gwmorris1@hotpop.com> wrote in message
news:uyQCUoZmEHA.896@TK2MSFTNGP12.phx.gbl...
> What the hell is this supposed to mean?
>
> "name" <nospam@user.com> wrote in message
> news:ea7UFVllEHA.1356@TK2MSFTNGP09.phx.gbl...
> >
> > Does your ng query take all words?
> >
> > Or only those from the Ms dictionary.
> >
> > =============================
> >
> > I am afraid your sense of reality is confined to
> >
> > insulated everyday monkey problems.
> >
> > ==============
> >
> > "DUPLICATE"
> >
> > Yep !
> >
> > Your most profound word.
> >
> > ====
> >
> >
> >
> >
> >
> >
> >
> >
> > "Freddy Hartono" <freddy_hartono@removethis.non.agilent.com> wrote in
> > message news:%234uQx7hlEHA.3712@TK2MSFTNGP15.phx.gbl...
> > > 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
> > >
> > >
> >
>
>