Get empty DL and delete them

How to get all distributions list on your organization which is empty using Powershell?

You have to use the following command:

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –eq 0 } | select PrimarySmtpAddress | export-csv C:\EmptyDL.csv

By the way, this command also working for Office 365, before that you have to connect to the office 365.

How to remove the empty distribution list?

Import-csv C:\EmptyDL.csv | foreach {foreach {Remove-DistributionGroup $_.PrimarySmtpAddress}

You can use on “-Confirm” in order to skip about confirmation.