PowerShell oneliner to find empty groups in Active Directory

This one goes in the category of a ‘nice & clean’ environment, specifically your Active Directory.

And to just get the names, simply pipe it to Select-Object and only select the ‘Name’ property.

Note: Go through the list before you’ll delete them. There may be default groups in there aswell as the groups may be in use in other products. So: Think before you act!

2 comments

  1. Ronnie Jorgensen says:

    Hi Jeff,

    A fellow PowerShell person helped me when your command above timed out on me. He suggested a different approach

    Get-ADGroup -Filter { GroupCategory -eq ‘Security’ -and member -notlike ‘*’ }

  2. Jeff Wouters says:

    Hi Ronnie,
    That would be a better approach indeed. Using a Filter parameter is always best, since it avoids using the pipeline (slow) 😀
    Jeff.

Leave a Reply

Your email address will not be published. Required fields are marked *