I am trying to create a batch file that asks to enter source samid and destination samid. Then using dsquery and dsget find out what security groups source samid is assigned to and assign destination samid to those security groups using dsmod.
Everything works except the dsmod group command. It doesnt do anything and batch file stops. If I literally put "CN=marketing,OU=test group,DC=abc,DC=com"
instead of %%g
and "CN=test1,OU=test group,DC=abc,DC=com"
instead of %dusercn%
, it works fine.
Can anyone help with this? I have pasted my scrip here. This last small thing is killing me.
echo off
echo %date% at %time%
set /p susername=enter source user name:
set /P dusername=enter destination user name:
echo %susername%
echo %dusername%
set dusercn=
%dusercn%=dsquery user -samid %dusername%
echo %dusercn%
for /f "tokens=*" %%g in ('dsquery user -samid %susername% ^|dsget user -memberof') do **(dsmod group %%g -addmbr %dusercn%)**
echo completed
pause
thanks for all your help. i am posting answer that worked for me. hopefully it helps other newbies like me.