modify DL group ownership

Roger Roger 4,951 Reputation points
2022-04-21T23:00:21.453+00:00

Hi All

i have a DLs in a csv file. These DLs have one owner user1@mydomain.com, i want to add user2@mydomain.com as a owner and remove user1@mydomain.com. please guide me how to do it from PowerShell. is the below syntax correct

dlalias
dl1@mydomain.com
dl2@mydomain.com

$DLList = import-CSV C:\temp\list.csv 
ForEach ($item in $DLList){Set-DistributionGroup -Identity "$DLList.dlalias" -ManagedBy @{Add="user2@mydomain.com"} -Confirm:$False -BypassSecurityGroupManagerCheck }
ForEach ($item in $DLList){Set-DistributionGroup -Identity "$DLList.dlalias" -ManagedBy @{Remove="user1@mydomain.com"} -Confirm:$False -BypassSecurityGroupManagerCheck }

For these DLs i want to modify delivery management settings i.e enable senders inside and outside of my organization by importing csv file. experts guide me.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,173 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,345 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,496 Reputation points Microsoft Vendor
    2022-04-22T02:50:42.413+00:00

    Hi @Roger Roger

    This script should be modified to:

     $DLList = import-CSV C:\temp\list.csv   
     ForEach ($item in $DLList){Set-DistributionGroup -Identity $item.dlalias -ManagedBy @{Add="user2@mydomain.com"} -Confirm:$False -BypassSecurityGroupManagerCheck }  
     ForEach ($item in $DLList){Set-DistributionGroup -Identity $item.dlalias -ManagedBy @{Remove="user1@mydomain.com"} -Confirm:$False -BypassSecurityGroupManagerCheck }  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Roger Roger 4,951 Reputation points
    2022-04-22T06:28:51.683+00:00

    For these DLs i want to modify delivery management settings i.e enable senders inside and outside of my organization by importing csv file.