This is a quick post for a small task I found the basis for the commands in Ying Li’s post here.
We had an admin leave us and go to Facebook recently. She was a member of a TON of our distribution groups set up for all of our Amazon Web Services account. Well, I couldn’t go into ECM and remove the user from the groups, and there were a bunch of them, so I really didn’t want to click each individual group and remove her. So, I did a quick google search and strung a command together remove the user from the groups.
All of our AWS accounts start with AWS, i.e. AWS-ClientName@company.com. So, this is what I came up with:
Get-DistributionGroup "AWS*" | Remove-DistributionGroupMember -member oldadmin
That worked like a charm. So, I then ran this command to add myself to those same groups:
Get-DistributionGroup "AWS*" | Add-DistributionGroupMember -member mrichardson
That too worked like a charm. I had some other cleaning up to do, so I encorporated a couple other commands to remove the old admin from all groups. That required two different commands:
Get-DistributionGroup "*" | Remove-DistributionGroupMember -member oldadmin Get-SecurityGroup "*" | Remove-SecurityGroupMember -member oldadmin
Of course I got errors for the groups she was not a member of, but that was to be expected. That pretty much sums it up. Hope this is helpful for someone.