Copy DynamicDistributionGroup Accepted Senders from One List to another

Hi,

I am trying to copy permissions from an old list to a few new ones.

gc = C:\ListofUsers.txt

$group = "All Users"

foreach ($user in $group)
{
Set-DynamicDistributionGroup -identity $group -AcceptMessagesOnlyFromSendersorMembers $user
}

When i run the above only the last person in the list is added to the group.

Please can someone help me as this list has about 50 users and its gonna be painful copying it across a few others.

February 4th, 2015 5:05pm

The ListOfUsers.txt contains:

User1
User2
User3
User4
User5

Free Windows Admin Tool Kit Click here and download it now
February 4th, 2015 5:20pm

Yes because its being overwritten each time. Try below.


ForEach ($User in $UserList)
     {
     Set-DynamicDistributionGroup -identity $group -AcceptMessagesOnlyFromSendersorMembers ((Get-DistributionGroup -DomainController myDC -identity "$group").AcceptMessagesOnlyFrom + "$User") -DomainController MYDC
     
     }

February 4th, 2015 5:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics