Show Empty AD Groups

This script was found on the following site and very useful for me when consolidating an Active Directory forest:

https://nidhinck.wordpress.com/2013/07/23/find-empty-groups-in-active-directory-using-powershell-script/

The script can be run from a normal Powershell window or with the Windows Powershell with AD Modules installed already (If you are using the AD Shell please delete the first line of this script)

Import-Module activedirectory
Get-ADGroup -Filter * -Properties Members | where {-not $_.members} | select Name | Export-Csv C:\emprtygroups.csv–NoTypeInformation

The Script gets all the AD Groups from the domain using the -Filter * (The * being a wildcard character to include everything) then is selects the Members property and pipes it into a script block which tells the script to only get empty AD Groups, pipes that info into a select statement so only the AD Groups name is shown, then finally pipes that data to be exported into a nice CSV.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.