Forum Discussion
How to add/remove allow sender of distribution group with powershell?
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.
sebgal you can do that using powershell
$UserCredential = Get-Credential
Connect-ExchangeOnline -UserPrincipalName <YourAdminEmail> -ShowProgress $true -UserCredential $UserCredential
Add-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 - sebgalAug 14, 2023Copper ContributorThank you, however when I run this script, I get this error:
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Connect-ExchangeOnline : A parameter cannot be found that matches parameter name 'UserCredential'.
At C:\Users\sebga\Documents\3.ps1:2 char:89
+ ... email address removed for privacy reasons -ShowProgress $true -UserCredential $UserCr ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Connect-ExchangeOnline], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Connect-ExchangeOnline
Add-DistributionGroupMember : The term 'Add-DistributionGroupMember' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At C:\Users\sebga\Documents\3.ps1:3 char:1
+ Add-DistributionGroupMember -Identity "All Movo Insurance" -Member "l ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Add-DistributionGroupMember:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException