Share via

Delete Distribution Lists

Glenn Maxwell 13,761 Reputation points
2022-05-13T10:35:41.11+00:00

Hi All

i am using exchange 2016 hybrid environment. i want to delete 50 distribution lists which are in exchange onprem. i have aliases in a csv file in the below format. is the below syntax correct. how can i use confirm false. when i delete it should not ask for confirmation.

Aliases
******@contoso.com
******@contoso.com
******@contoso.com


$DLList = import-CSV "C:\list.csv"
ForEach ($item in $DLList){Remove-DistributionGroup -Identity $item.Aliases -BypassSecurityGroupManagerCheck $false}
Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management

The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.

Exchange | Hybrid management
Exchange | Hybrid management

The administration of a hybrid deployment that connects on-premises Exchange Server with Exchange Online, enabling seamless integration and centralized control.

0 comments No comments

Answer accepted by question author

Andy David - MVP 160.3K Reputation points MVP Volunteer Moderator
2022-05-13T11:23:18.283+00:00

Yes, this will work, but you need to make a few changes. See below
Add this to not get prompted.
Test with just a few first!!!!

ForEach ($item in $DLList){Remove-DistributionGroup -Identity $item.Aliases -BypassSecurityGroupManagerCheck $true -Confirm:$false}

Note that I set -BypassSecurityGroupManagerCheck $true. You need that true to process

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.