Importing members in a Distribution Group

Just a gentle request

Is there a script that will import members in a distribution group ? these members will have to be imported in the section ‘message approval’ as “Senders who don’t require message approval”

thanks

It could be that there’s a script floating around on the internet. But… did you do a search yourself? Have you tried to create a script on your own? If so, we’re happy to help!

$Users = Get-Content C:\Users.txt
$Groups = Get-Content C:\groups.txt
ForEach ($Group in $Groups) {
   Set-DistributionGroup $Group -AcceptMessagesOnlyFrom((Get-DistributionGroup $Group).AcceptMessagesOnlyFrom + $Users)
}

Users.txt needs to contain the Alias or Samaccountname of users
groups.txt needs to contain the alias of group(s)

Dear Mr. Prior:

Just a gentle note of thanks; incidentally, I wasn’t clear on the objective of the script please, note the revised information

The script should allow a list of users to “ByPassTheModerator” when sending email

much appreciated

thanks

Insan, if you read through the technet on set-distributiongroup, and search the page for moderator you will see:
BypassModerationFromSendersOrMembers

as far as how to add them to this list, it really depends on exactly what you want to add, the example in the technet is pretty self-explanatory:
To enter multiple senders and overwrite any existing entries, use the following syntax: ,… If the values contain spaces or otherwise require quotation marks, use the following syntax: “”,“”…
To add or remove one or more senders without affecting any existing entries, use the following syntax: @{Add=“”,“”…; Remove=“”,“”…}.

https://technet.microsoft.com/en-us/library/bb124955(v=exchg.160).aspx

i don’t have free time today to try and bash out a functioning script but with the information provided in the tech-net, and Mark’s example, it shouldn’t be to bad

Thanks, Mr. David Schmidtberger:

It’s giving me a hard time please, see below:

Set-DistributionGroup -identity “traffic” -ModerationEnabled $true -ModeratedBy “test1” -BypassModerationFromSendersOrMembers @{ADD =“test2”}

  1. moderation enabled - OK

  2. ModeratedBy - OK

  3. @{ADD =“test2”} this is not working it doesn’t add any accounts - tried with email address, alias, first name and last name

  4. manually added test2

  5. rerun this command
    Set-DistributionGroup -identity “traffic” -ModerationEnabled $true -ModeratedBy “test1” -BypassModerationFromSendersOrMembers @{ADD =“test2”}

  6. Result test2 was removed

thanks

take a look here:
https://technet.microsoft.com/en-us/library/jj983442(v=exchg.150).aspx

there are examples of what you want to do.

i’ve never personally set this attribute, but combined with the set-distributiongroup technet, it looks like it accepts the following: Name
Display name
Alias
Distinguished name (DN)
Canonical DN
Email address
GUID