ZIMBRA : Import Mail accounts from CSV file with ZMPROV in a Shell Bash Script.
There few things to change in the script. Depending of you CSV file.
In the picture above I have 4 columns in my CSV file. So in the script shell you must
identified the number of each colomns you need in your script.
So see the script below :
#!/bin/bash
while read LINE; do
email=$(echo $LINE | awk -F ";" '{print $4}')
fn=$(echo $LINE | awk -F ";" '{print $2}')
ln=$(echo $LINE | awk -F ";" '{print $3}')
echo -e "Importing All Accounts in Zimbra .... $email\n"
CMD=$(zmprov createAccount $email password displayName "${fn} ${ln}" givenName "${fn}" sn "${ln}")
$CMD
echo -e "Done !\n"
echo "Modifying $email password…";
CMD1=$(zmprov sp $email changeme1)
$CMD1
CMD2=$(zmprov ma $email zimbraPasswordMustChange TRUE)
$CMD2
echo -e "Modifying password is OK !\n";
done < /tmp/scripts/UserAccounts.csv
echo "............... ALL OPERATIONS DONE ! ................"
If you have questions please feel free to ask !