# Get all user usernames and aliases
user@cloudshell$ gam print users > users.csv
user@cloudshell$ gam print aliases > alias.csv
user@cloudshell$ gam print groups > groups.csv
# Make a list to transition user emails which were aliases to the new secondary domain status
Open users.csv in Sheets, and add new column header newEmail
Duplicate the username column (primaryEmail) into newEmail and replace @primary-domain.com with @alias-domain.com
Download and Save as newdomain.csv
# Make a list to transition group emails which were aliases to the new secondary domain status
# Delete the domain alias
user@cloudshell$ gam delete domainalias domain.com
# Create the domain as a secondary domain
user@cloudshell$ gam create domain domain.com
# Validate the domain if necessary. It may validate automatically as in testing
# Get Domain Verification details
user@cloudshell$ gam create verify domain.com
Go to your DNS provider and use verification details from the previous step
# After waiting briefly, try to verify the new domain
user@cloudshell$ gam update verify domain.com TXT
# Add the new secondary domain addresses as aliases to the primary
user@cloudshell$ gam csv newdomain.csv gam create alias ~newEmail user ~primaryEmail
user@cloudshell$ gam csv groups.csv gam create alias ~alias group ~groupEmail
#Add back user alias addresses
user@cloudshell$ gam csv alias.csv gam create alias ~aliasEmail1 user ~username
user@cloudshell$ gam csv alias.csv gam create alias ~aliasEmail2 user ~username