locked
How to edit message delivery restrictions for distribution group via PS? RRS feed

  • Question

  • Hi,

    I need to edit some distribution group to accept messages from new user. I tried with this:

    Get-DistributionGroup | where {$_.AcceptMessagesOnlyFromSendersOrMembers -ne $null}
    | Set-DistributionGroup -AcceptMessagesOnlyFromSendersOrMembers Rajco

    but that command set accept delivery only for new user(rajco) and I need to add this user and old to keep permision.

    Thank!

    Tuesday, January 10, 2012 12:31 PM

Answers

  • Hi

    Try the script below

    ----------------------------------------------------------------------------------------

    $DGs = Get-DistributionGroup

    Foreach ($DG in $DGs) {

    $List = $DG.acceptmessagesonlyfrom

    $List+="Rajco"

    $DG | Set-DistributionGroup -AcceptMessagesOnlyFrom $List

    }

    -----------------------------------------------------------------------------------------

    Cheers

    Zi Feng

     


    • Edited by Zi FengModerator Thursday, January 12, 2012 3:32 AM
    • Marked as answer by rajco Thursday, January 12, 2012 7:13 AM
    Thursday, January 12, 2012 3:32 AM
    Moderator

All replies

  • Hi

    Please take your time and ammend this to suite your requirements, this helps you ammend one distribution list, Iam sure you can modify to cater for more groups

    $DG = Get-DistributionGroup "Your Group"

    Get-DistributionGroupMember "tempDG" | foreach {$DG.acceptmessagesonlyfrom += $_.DistinguishedName}

    Set-DistributionGroup "Your Group" -AcceptMessagesOnlyFrom $DG.acceptmessagesonlyfrom


    Regards Herbert Zimbizi
    Tuesday, January 10, 2012 1:39 PM
  • Hi

    Try the script below

    ----------------------------------------------------------------------------------------

    $DGs = Get-DistributionGroup

    Foreach ($DG in $DGs) {

    $List = $DG.acceptmessagesonlyfrom

    $List+="Rajco"

    $DG | Set-DistributionGroup -AcceptMessagesOnlyFrom $List

    }

    -----------------------------------------------------------------------------------------

    Cheers

    Zi Feng

     


    • Edited by Zi FengModerator Thursday, January 12, 2012 3:32 AM
    • Marked as answer by rajco Thursday, January 12, 2012 7:13 AM
    Thursday, January 12, 2012 3:32 AM
    Moderator
  • Thanks Zi Feng, that script is working exactly what I need.
    Thursday, January 12, 2012 7:14 AM