Answered by:
Powershell script to restrict access to a distributiongroup

Question
-
Hi,
I am working on a Powershell script to restrict sending messages to certain distributiongroups. I'm reading the information from a CSV file and
the cmdlet is set-distributiongroup -identity $CSV.Group -AcceptMessagesOnlyFromSendersOrMembers $CSV.Accepts
the problem is that AcceptMessagesOnlyFromSendersOrMembers is a multivalued property. How can I put the separate smtp addresses into a variable, which is understood by the above cmdlet? Any samples?
regards, Richard NeuteboomTuesday, March 15, 2011 12:27 PM
Answers
-
Hi Richard,
I would suggest you seek the solution in the Development Forum:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads
Just for reference: It is easier if you can create a temp DG to include the mail addresses. The following cmdlets are to add all members of the tempDG to "Only senders in the following list" of restricted DG.
$DG = Get-DistributionGroup "restricted DG"
Get-DistributionGroupMember "tempDG" | foreach {$DG.acceptmessagesonlyfrom += $_.DistinguishedName}
Set-DistributionGroup "restricted DG" -AcceptMessagesOnlyFrom $DG.acceptmessagesonlyfrom
Please use AcceptMessagesOnlyFrom instead of AcceptMessagesOnlyFromSendersOrMembers.
Frank Wang
TechNet Subscriber Support in forum
If you have any feedback on our support, please contact tngfb@microsoft.com
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by emma.yoyo Tuesday, March 22, 2011 2:22 AM
Wednesday, March 16, 2011 8:17 AM
All replies
-
how is the Accepts column in your csv file look like?
give a sample?
-join("74686979616775313440686F746D61696C2E636F6D"-split"(?<=\G.{2})",21|%{[char][int]"0x$_"}) www.myExchangeWorld.com This posting is provided "AS IS" with no warranties, and confers no rights.Tuesday, March 15, 2011 12:57 PM -
you can update multivalue property like this:
Set-DistributionGroup "Group1" -AcceptMessagesOnlyFromSendersOrMembers user1@domain.com,user2@domain.com
-join("74686979616775313440686F746D61696C2E636F6D"-split"(?<=\G.{2})",21|%{[char][int]"0x$_"}) www.myExchangeWorld.com This posting is provided "AS IS" with no warranties, and confers no rights.Tuesday, March 15, 2011 1:01 PM -
it looks like this:
Group;Accepts
samplegroup;user1@mydomain.com,user2@mydomain.com,user3@mydomain.com
regards, Richard NeuteboomTuesday, March 15, 2011 1:15 PM -
Hi Richard,
I would suggest you seek the solution in the Development Forum:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads
Just for reference: It is easier if you can create a temp DG to include the mail addresses. The following cmdlets are to add all members of the tempDG to "Only senders in the following list" of restricted DG.
$DG = Get-DistributionGroup "restricted DG"
Get-DistributionGroupMember "tempDG" | foreach {$DG.acceptmessagesonlyfrom += $_.DistinguishedName}
Set-DistributionGroup "restricted DG" -AcceptMessagesOnlyFrom $DG.acceptmessagesonlyfrom
Please use AcceptMessagesOnlyFrom instead of AcceptMessagesOnlyFromSendersOrMembers.
Frank Wang
TechNet Subscriber Support in forum
If you have any feedback on our support, please contact tngfb@microsoft.com
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by emma.yoyo Tuesday, March 22, 2011 2:22 AM
Wednesday, March 16, 2011 8:17 AM -
Hi Frank,
Thanks for your help. I have got the script working for a single group and reading the members from a csv file. the next time I will search the Developement forum. I need to enhance the script so that it can read the groups and members from a CSV file, because I need to migrate about 1400 distribution groups from a Unix Listserver.
regards, Richard NeuteboomWednesday, March 16, 2011 2:26 PM -
Worked for me, super THX!Friday, September 8, 2017 6:08 AM