Email & collaboration

How to list members in distribution lists

Zimbra_Logo A script to list users in every distribution list in the system, showing the results by distribution list, as in this example.


=======  GROUP: dist1 =============
user1 ezy, user1@ezymailhosting.local
user3 ezy, user3@ezymailhosting.local
user5 ezy, user5@ezymailhosting.local

=======  GROUP: allgroup =============
administrator, admin_zimbra@ezymailhosting.com
Peerapach, peerapach@ezymailhosting.com

=======  GROUP: dist2 =============
euro1, euro1@ezymailhosting.com
euro2, euro2@ezymailhosting.com

Script to list users in every distribution list in the system

#!/bin/bash
for DIST in `zmprov gadl`
do
    DISTNAME=`echo ${DIST} |cut -f1 -d@ `
    echo " =======  GROUP: ${DISTNAME} ============="
    for LISTNAME in `zmprov gdlm ${DIST}|egrep -v "#|member|^$|galsync"`
    do
        ALL=`zmprov -l ga ${LISTNAME}`
        echo "$ALL" > /tmp/ondetail.txt
        DISPLAYNAME=`grep -i "displayName:" /tmp/ondetail.txt |awk '{ print $2 }'`
        echo ${DISPLAYNAME}, ${LISTNAME}
    done
done
EOF.← Back to articles