question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked AndyDavid edited

Delete Distribution Lists

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
 dl1@contoso.com
 dl2@contoso.com
 dl3@contoso.com
    
    
 $DLList = import-CSV "C:\list.csv"
 ForEach ($item in $DLList){Remove-DistributionGroup -Identity $item.Aliases -BypassSecurityGroupManagerCheck $false}
office-exchange-server-administrationoffice-exchange-online-itprooffice-exchange-server-mailflowoffice-exchange-hybrid-itpro
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AndyDavid avatar image
0 Votes"
AndyDavid answered AndyDavid edited

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.