Forum Discussion
null null
Apr 12, 2017Copper Contributor
Powershell to remove empty security groups
Just getting into Azure and imported a bunch of empty Security Groups into Azure AD. Trying to sort out a way to delete Groups if they have 0 members. Anyone got a quick way to do that?
Thank you.
Chris
Try something like this:
Get-MsolGroup -GroupType Security | ? {(Get-MsolGroupMember -GroupObjectId $_.ObjectId).count -eq 0 }
- null nullCopper ContributorThank you, that does get me a list of empty groups, I can pipe that to a file and use that to remove them I think.