Forum Discussion
How to add/remove allow sender of distribution group with powershell?
sebgal to add a user as a sender to a DL , try the below
# Connect to Exchange Online
$UserCredential = Get-Credential
Connect-ExchangeOnline -UserPrincipalName $UserCredential.UserName
# Replace "DistributionGroupName" with the actual name of your distribution group
$GroupName = "DistributionGroupName"
$NewSender = "email address removed for privacy reasons"
# Add the new sender to the distribution group
Add-DistributionGroupMember -Identity $GroupName -Member $NewSender
# Disconnect from Exchange Online
Disconnect-ExchangeOnline -Confirm:$false
To remove as sender from DL, try the below
# Connect to Exchange Online
$UserCredential = Get-Credential
Connect-ExchangeOnline -UserPrincipalName $UserCredential.UserName
# Replace "DistributionGroupName" with the actual name of your distribution group
$GroupName = "DistributionGroupName"
$SenderToRemove = "email address removed for privacy reasons"
# Remove the sender from the distribution group
Remove-DistributionGroupMember -Identity $GroupName -Member $SenderToRemove -Confirm:$false
# Disconnect from Exchange Online
Disconnect-ExchangeOnline -Confirm:$false
- sebgalAug 14, 2023Copper Contributor
elieelkarkafiMany thanks for getting back to me.
Your script functions excellently if I intend to add or remove a user to or from the Distribution List.
I've given it a go, and it's certainly proven to be very helpful - saved for future reference. 🙂
However, it's of particular importance for me to add a user (who is already a member of this Distribution List) to the group of senders permitted to email this distribution group email. Kindly refer to the screenshot below. I attempted to achieve this through the Office 365 Exchange portal, but I encountered an error: "Argument passed in is not serializable. Parameter name: value."
That's the reason I'm attempting to use PowerShell to accomplish this task instead.
- Aug 14, 2023
sebgal you can do that using powershell
$UserCredential = Get-Credential
Connect-ExchangeOnline -UserPrincipalName <YourAdminEmail> -ShowProgress $true -UserCredential $UserCredentialAdd-DistributionGroupMember -Identity "DistributionListName" -Member "email address removed for privacy reasons", "email address removed for privacy reasons"
Disconnect-ExchangeOnline -Confirm:$false
- sebgalAug 14, 2023Copper ContributorThis is the script I used:
$UserCredential = Get-Credential
Connect-ExchangeOnline -UserPrincipalName email address removed for privacy reasons -ShowProgress $true -UserCredential $UserCredential
Add-DistributionGroupMember -Identity "All Movo Insurance" -Member "email address removed for privacy reasons"
Disconnect-ExchangeOnline -Confirm:$false