Importing members in a Distribution Group

This topic contains 6 replies, has 4 voices, and was last updated by  David Schmidtberger 2 years, 3 months ago.

  • Author
  • #38012

    Insan Mohamed

    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"


  • #38030

    Richard Diphoorn

    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!

  • #38031

    Mark Prior
    $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)

  • #38122

    Insan Mohamed

    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


  • #38127

    David Schmidtberger

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

    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="",""...}.

    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

  • #38184

    Insan Mohamed

    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


  • #38185

    David Schmidtberger

    take a look here:

    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
    Distinguished name (DN)
    Canonical DN
    Email address

You must be logged in to reply to this topic.