Distribution List Syntax

Glenn Maxwell 13,141 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

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.
{count} votes

Answer accepted by question author
  1. Jame Xu-MSFT 4,191 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.