none
add object to AcceptMessagesOnlyFromDLMembers for multiple groups RRS feed

  • Question

  • Hi,

    I need to add a DL to AcceptMessagesOnlyFromDLMembers attribute of SOME groups (not only one)

    I have a powershell commad to do it for only one group.

    Set-DistributionGroup -id 'DL01' -AcceptMessagesOnlyFromDLMembers ((Get-DistributionGroup 'DL01').AcceptMessagesOnlyFromDLMembers + 'InfoDL')

    I get my DL list with,

    Get-DistributionGroup -ResultSize unlimited -OrganizationalUnit domain.local/hosting/customer.com | where {($_.AcceptMessagesOnlyFrom -like "*") -or ($_.AcceptMessagesOnlyFromDLMembers -like "*")}

    I want to add InfoDL to restrictions of customers.com DLs.

    What is the best way to do it?


    Those who are skilled in combat do not become angered, those who are skilled at winning do not become afraid. Thus the wise win before the fight, while the ignorant fight to win.


    Tuesday, June 5, 2012 12:05 PM

Answers

  • Hi

    You can try the Script below

    $dls = Get-DistributionGroup -ResultSize unlimited -OrganizationalUnit domain.local/hosting/customer.com | where {($_.AcceptMessagesOnlyFrom -like "*") -or ($_.AcceptMessagesOnlyFromDLMembers -like "*")}

    Foreach($dl in $dls){

    Set-DistributionGroup -id $dl.Alias -AcceptMessagesOnlyFromDLMembers ((Get-DistributionGroup $dl.Alias).AcceptMessagesOnlyFromDLMembers + 'InfoDL')

    }

    Hope it works

    Cheers


    Zi Feng

    TechNet Community Support

    Wednesday, June 6, 2012 9:22 AM
    Moderator

All replies

  • Hi

    You can try the Script below

    $dls = Get-DistributionGroup -ResultSize unlimited -OrganizationalUnit domain.local/hosting/customer.com | where {($_.AcceptMessagesOnlyFrom -like "*") -or ($_.AcceptMessagesOnlyFromDLMembers -like "*")}

    Foreach($dl in $dls){

    Set-DistributionGroup -id $dl.Alias -AcceptMessagesOnlyFromDLMembers ((Get-DistributionGroup $dl.Alias).AcceptMessagesOnlyFromDLMembers + 'InfoDL')

    }

    Hope it works

    Cheers


    Zi Feng

    TechNet Community Support

    Wednesday, June 6, 2012 9:22 AM
    Moderator
  • As it is a hosted environment sometimes alias may match multiple objects. For those objects, it throw an error.

    Thank you for your help.


    Wednesday, June 6, 2012 10:26 AM