I was helping a fellow expert on Experts-Exchange recently. They were needing help with a PowerShell script. The task was to allow a user account Full Mailbox Access overall members that belonged to a certain distribution group. After a little reworking of PowerShell, this is what we came up with; and it worked!
C:\> Get-DistributionGroupMember “Test Group” | foreach-Object { Add-MailboxPermission $_.Name –AccessRights FullAccess –user "testaccess"}
Note: Sometimes the quotation marks don’t cut and paste correctly. If this code fails, remove and retype the quotation marks after pasting.
What this script does is enumerate all members from a distribution group called Test Group. It then pipes those results directly into Add-MailboxPermission cmdlet.
The permissions granted are FullAccess, which is designated by the -AccessRights switch. Our user account is TestAccess that is designated by -User switch.
The value $_.Name is one of the properties of the object we are piping from Get-DistributionGroupMember.
Alternatively, if we wanted all users of a distribution group to have Full Mailbox Access to a single shared mailbox we could just flip some of the syntaxes around.
C:\> Get-DistributionGroupMember “Test Group” | foreach-Object { Add-MailboxPermission "testaccess" –AccessRights FullAccess –user $_.Name}
Note: Sometimes the quotation marks don’t cut and paste correctly. If this code fails, remove and retype the quotation marks after pasting.
Leave a Reply