Sunday, December 25, 2011

Exporting all Email Accounts from Zimbra Server for Microsoft Transporter Suite

Hello Everyone,

In order to move all email accounts and data from IMAP or POP3 Zimbra Server in Linux box machine to Exchange Server 2007, we need to create a .CSV file with the following columns:
  • SourceIdentity: The e-mail account that the user has in the IMAP/POP3 Server
  • SourceServer: The name or IP of the IMAP/POP3 Server
  • SourceLoginID: the account user name used to connect on the IMAP/POP3 server
  • SourcePassword: the user’s password
  • TargetIdentity: the Exchange Server 2007 identity will receive the data from the previous IMAP/POP3 Server settings  
To make life easier, I made a script that export all users from Zimbra to a CSV file. 
Here is the script:

#!/bin/bash
clear
echo "Processing account, please wait.............................."
USERS=`su - zimbra -c 'zmprov -l gaa'`
#Assume that domain name is test.com
exchange="@test.com"
echo "SourceIdentity,SourceServer,SourceLoginID,SourcePassword,TargetIdentity" > export_users.csv
for ACCOUNT in $USERS
 do
  SourceIdentity=`echo $ACCOUNT`
  #Assume that domain name is xyz.com for Linux box and Zimbra
  SourceServer=`echo "xyz.com"`
  SourceLoginID=`echo $ACCOUNT | awk -F@ '{print $1}'`
  SourcePassword=`echo "P@ssw0rd"`
  TargetIdentity=`echo -n $ACCOUNT | awk -F@ '{print $1}'`
  TargetIdentity=${TargetIdentity}${exchange}
  if [ $SourceLoginID == "admin" ] || [ $SourceLoginID == "spam" ] || [ $SourceLoginID == "ham" ] || [ $SourceLoginID == "virus-quarantine" ]
  then
   echo "Skipping system account, $ACCOUNT..."
  else
   echo "$SourceIdentity,$SourceServer,$SourceLoginID,$SourcePassword,$TargetIdentity" >> export_users.csv
  fi
 done



Now, we can use this CSV file in Microsoft Transporter Suite to import users to Exchange 2007.
Hope enjoy using this script. Please leave your comments or questions. I will try to answer as soon as possible.
Thanks,
Khosro Taraghi

3 comments: