Estou postando uma resposta que funcionou para mim. Espero que ajude outros novatos como eu.
echo off
echo %date% at %time%
set /p susername=enter source user name:
set /P dusername=enter destination user name:
rem echo+ is used for new line. echo+
echo entered source user name: %susername%
echo entered destination user name: %dusername%
echo+
set dusercn=0
set lines=0
for /f "tokens=*" %%g in ('dsquery user -samid %susername% ^|dsget user -memberof') do (
echo %%g
dsquery user -samid %dusername% | dsmod group %%g -addmbr -c
set /a lines=lines+1
)
echo+
echo+
echo **************
echo number of lines processed %lines%
echo script completed
echo **************
pause