top of page
Writer's pictureAvijit Dutta

PowerShell to get the QBDL (Query Based Distribution List) details

Updated: Sep 21, 2022

Article No :: KB00010



Microsoft, with Windows Server 2003 and Exchange Server 2003 has introduced a new group type called “Queries-Based Distribution groups”. These distribution groups are created based on LDAP queries. These are dynamic, and the members are dynamically inserted or removed from the group when they fall under the scope of the group’s LDAP-basearch filter.


Note: Microsoft has discontinued this distribution group type with Dynamic Distribution Group.


Today, we’ll use PowerShell to fetch the details of QBDL and test the LDAP query. If you still have QBDL's, you can use the PowerShell and LDAP Query to fetch the user informations. Below commands will help you with the same.


1) Command to get the QBDL Details.


Get-DynamicDistributionGroup -OrganizationalUnit "OU=QBDL,OU=Groups,DC=VirtualGyanis,DC=com" | select DisplayName,PrimarySmtpAddress,MaxSendSize,MaxReceiveSize,HiddenFromAddressListsEnabled,OrganizationalUnit,LdapRecipientFilter | Export-Csv C:\newQBDL.csv


Note: OU Path = OU where your QBDL are present. In my case, it is "OU=QBDL,OU=Groups,DC=VirtualGyanis,DC=com"


2) Command to test the QBDL and get the members details. We can use below two methods to fetch the information.


1st Method

First we need the LDAP query to get the member information. For LDAP query, run the below command:

Get-DynamicDistributionGroup -Identity "QBDLGroupName" | select *filter* | fl


Now, we will use the CSVDE command to export the members details with the LDAP query. Copy the LDAP query get from the above command and replace the same in below command with <LDAP QUERY>.

csvde -f C:\<filename>.csv -l mail -r “<LDAP Query>”

The -f is your output file, -l mail means only output the primary smtp address, it’s an optional switch so you can leave out and get all the fields, but the csv file can get very large. –r is for the LDAP query.


2nd Method

We will use the below Active Directory command to get the information of QBDL groups. In the below example, QBDL Group name is "QBDLGroupName".

get-aduser -LDAPFilter "(&(!cn=SystemMailbox{*})(!userAccountControl:1.2.840.113556.1.4.803:=2)(objectCategory=user)(Displayname=*QBDLGroupName*))" -Properties * | select name,displayname,mail,SamAccountName,userAccountControl,canonicalname | Export-Csv m:/QBDL.csv



If you liked this article, do share the same. You can also Buy me a Coffee using Paypal at "paypal.me/duttaavijit", This is purely a volunteer effort. THANK YOU !!!


2,205 views0 comments

Recent Posts

See All

Commenti


bottom of page