Home ยป PowerShell ยป How to Get Distribution List Members in PowerShell

How to Get Distribution List Members in PowerShell

The PowerShell command to get distribution list members is `Get-DistributionGroupMember`. This command is used to view the members of the distribution groups and mail-enabled security groups.

Here, is the PowerShell command to get distribution list members:

Get-DistributionGroupMember -Identity <DistributionGroupDN>

In this article, we will discuss how to get distribution list members using the PowerShell Get-DistributionGroupMember command.

How to Get Members of the Distribution Groups in PowerShell

Use the PowerShell cmdlet `Get-DistributionGroupMember` to list of all the users who are members of the distribution group.

To get the members of the distribution group FinanceTeam, you can use the following command.

Get-DistributionGroupMember -Identity FinanceTeam

In the above PowerShell script, the Get-DistributionGroupMember command uses the Identity parameter to specify the distinguished name (DN) of the distribution group and return a list of all the members of the distribution group.

Get Distribution Group Members in the Worldwide Distribution Group

To get distribution group members in the Worldwide distribution group, you can use the Get-DistributionGroupMember command to search the entire forest for the distribution group members.

Set-ADServerSettings -ViewEntireForest $true

Get-DistributionGroupMember -Identity "SalesTeam"

In the above PowerShell script, the first Set-AdServerSettings cmdlet sets the scope of the search to the entire forest. Last, the Get-DistributionGroupMember cmdlet searches the entire forest for the distribution group members in the SalesTeam Worldwide distribution group and lists all the members of the group.

Cool Tip: How to get distribution groups using PowerShell!

Conclusion

I hope the above article on how to get members of the distribution group using the PowerShell command Get-DistributionGroupMember is helpful to you.

To find all the users of the distribution group, the distribution group must be created in Active Directory and the user who runs the command must have permission to view the distribution group members.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.