You will need to take 2 steps to accomplish this. First is to get the list of user groups you need, and second is to assign those groups to the new userid.
To generate the list of user groups, you will need to use SQL. Here is an example statement that would do the trick:
SELECT DISTINCT HARUSERGROUP.USERGROUPNAME
INNER JOIN HARUSERSINGROUP ON HARUSER.USROBJID = HARUSERSINGROUP.USROBJID
INNER JOIN HARUSERGROUP ON HARUSERGROUP.USRGRPOBJID = HARUSERSINGROUP.USRGRPOBJID
WHERE HARUSER.USERNAME = 'harvest' /* <--- The userid assigned to the list of groups you want goes here */
Once you have the list of user groups, you will need to use the "HUSRMGR" command line utility to assign the new user to the same list of groups. Here is where you can read about this command: https://docops.ca.com/ca-harvest-scm/13-0/en/command-reference/get-started-with-ca-harvest-scm-commands/husrmgr-command-user-manager
This command lets you add new users as well as update existing users according to a data entry file you will construct.