Powershell script to restrict access to a distributiongroup
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 Neuteboom
March 15th, 2011 8:38am

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.
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2011 8:58am

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.
March 15th, 2011 9:02am

it looks like this: Group;Accepts samplegroup;user1@mydomain.com,user2@mydomain.com,user3@mydomain.comregards, Richard Neuteboom
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2011 9:16am

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.
March 16th, 2011 4:18am

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 Neuteboom
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2011 10:27am

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

Other recent topics Other recent topics