Distribution List Syntax

Glenn Maxwell 12,336 Reputation points
2023-01-01T16:37:06.643+00:00

Hi All

I am using exchange 2016 hybrid environment. I want to modify the Onprem DL Ownership. i have csv file in the below format. i.e i want to add owner and remove owner.
for example: for DL1 i want to add user1 as owner and remove admin1 as owner. in the same way i want to do for other DLs.
please correct with the below syntax.

$List = import-CSV c:\temp\input.csv   
ForEach ($item in $List){Set-DistributionGroup -Identity $item.DLAlias -ManagedBy @{Add=$_.AddOwner} @{Remove=$_.RemoveOwner} -Confirm:$False -BypassSecurityGroupManagerCheck }  

275295-mg.jpg

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,737 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,785 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
2,221 questions
{count} votes

Accepted answer
  1. Jame Xu-MSFT 4,176 Reputation points
    2023-01-02T09:57:57.86+00:00

    Hi @Glenn Maxwell ,
    You could use the following syntax:

    ForEach ($item in $List){Set-DistributionGroup -Identity $item.DLAlias -ManagedBy @{Add=$item.AddOwner;Remove=$item.RemoveOwner} -Confirm:$False -BypassSecurityGroupManagerCheck }  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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