As part of our spring cleaning series, I have a quick tip for you to delete all empty security groups.
Get-qadgroup -SearchRoot "DC=Test,DC=local" -SearchScope Subtree -empty $true | Remove-QADObject -whatif
That’s it! For safety, I added the -whatif parameter. It will simulate the deletion but not actually delete anything. If you are worried that your groups are used for shares, you can find out by using this PowerShell Script. If you would like to test your group deletion without messing anything up, switch the group type from security to distribution. If no one complains after a month, you can delete it then. As always, happy scripting!