?
Solved

Remove All Members from Distribution Group using PowerShell

Posted on 2009-04-24
8
Medium Priority
?
8,306 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:advserver
  • 4
  • 2
  • 2
8 Comments
 
LVL 5

Expert Comment

by:mrmarkfury
ID: 24225403
Have you tried this?
Remove-DistributionGroupMember -Identity "Group Name" -Member *

Open in new window

0
 
LVL 4

Author Comment

by:advserver
ID: 24225598
 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 *
0
 
LVL 5

Expert Comment

by:mrmarkfury
ID: 24225879
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?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 4

Author Comment

by:advserver
ID: 24225913
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!
0
 
LVL 65

Accepted Solution

by:
Mestha earned 2000 total points
ID: 24225995
I haven't tried it, but if you get the membership of the group, then pipe it, that should do it.

get-distribitutiongroupmember "groupname" | remove-distributiongroupmember groupname

I haven't tried it, so it is theoretical.

Simon.
0
 
LVL 4

Author Comment

by:advserver
ID: 24226103
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.  
0
 
LVL 65

Assisted Solution

by:Mestha
Mestha earned 2000 total points
ID: 24226904
You aren't confirming that you want to do it with the -confirm switch, you are saying you don't want to see the confirm prompt.

I believe it is this:

"-Confirm:$false"

Simon.
0
 
LVL 4

Author Closing Comment

by:advserver
ID: 31574227
Thank you very much for your help!  That worked perfectly!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question