need a quest AD cmdlets script or powershell script to bulk delete distribution groups

can someone provide a Quest AD cmdlets or posh script that I can use to key on an input .csv file [with primary email address of each distribution group] and delete all in the csv?

many thanks!

Who is Participating?
SubsunConnect With a Mentor Commented:
In case you want to use Quest AD PowerShell..
Import-Csv C:\input.csv | % {Get-QADGroup $_.SMTP | Remove-QADObject -Force}

Open in new window

Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
The following Powershell Script will do the trick for you...

Import-Module activedirectory
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
$DelDisGroup = Import-Csv "yourCSVhere.csv"
foreach ($Group in $DelDisGroup) {
remove-distributiongroup -identity $Group.SMTP

note: make sure that the CSV file has a heading of SMTP and then all of the smtp addresses are underneth.

Hope this helps!
siber1Author Commented:
thanks Spec01, is there a way to run this without it prompting for each deletion?
Will SzymkowskiSenior Solution ArchitectCommented:
Yeah just add the -confirm $false switch and that should do it.

remove-distributiongroup -identity $Group.SMTP -confirm $false
siber1Author Commented:
thanks Subsun, that worked perfectly. as did yours Spec01.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.