Link to home
Start Free TrialLog in
Avatar of advserver
advserverFlag for United States of America

asked on

Remove All Members from Distribution Group using PowerShell

Is there a way using the "Remove-DistributionGroupMember" command to remove all members from a distribution group instead of having to type in each member?
Avatar of mrmarkfury
mrmarkfury
Flag of United States of America image

Have you tried this?
Remove-DistributionGroupMember -Identity "Group Name" -Member *

Open in new window

Avatar of advserver

ASKER

 The error I received after trying -Member *  is listed below.  Thank you for your quick response!  Any other suggestions are greatly appreciated.


Remove-DistributionGroupMember : There are multiple recipients matching the ide
ntity "*". Please specify a unique value.
At C:\Documents and Settings\--\Desktop\removedg.ps1:1 char:31
+ remove-distributiongroupmember  <<<< -identity "dg72" -member *
Apparently that cmdlet only allows for the removal of a unique member. Could you instead run Remove-DistributionGroup to delete the group, and then create a new one using New-DistributionGroup?
I was trying to avoid doing that but it appears that might have to be the solution.  This command will be running on a daily basis.  I will try it out and let you know!  Once again thanks for your quick response!
ASKER CERTIFIED SOLUTION
Avatar of Mestha
Mestha
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mestha,

That worked!  Do you know the proper syntax for the [-Confirm [<SwitchParameter>]] ?  I attempted [-Confirm [A]]   -Confirm [A]  and -Confirm A and all failed.  
EXPERT CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for your help!  That worked perfectly!