Quantcast
Channel: Microsoft – JeffOps
Viewing all articles
Browse latest Browse all 120

PowerShell oneliner to find empty groups in Active Directory

$
0
0

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

Get-ADGroup -Filter {GroupCategory -eq 'Security'} | Where-Object {@(Get-ADGroupMember $_).Length -eq 0}

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

Get-ADGroup -Filter {GroupCategory -eq 'Security'} | Where-Object {@(Get-ADGroupMember $_).Length -eq 0} | Select-Object -Property Name

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!


Viewing all articles
Browse latest Browse all 120

Trending Articles