Add all licensed users to a Mail Enabled Security Group and then assign permissions to RecipientType.

Yesterday I had to add all licensed users to a Mail Enabled Security Group and then add that group to Room, Equipment and user mailboxes with desired permissions.

To add all Licensed users to a group:

$users =
Get-MsolUser |
Where-Object { $_.isLicensed -eq
“TRUE” }

$users |
foreach {Add-DistributionGroupMember
-identity Mail_Enabled_Security_Group
-Member $_.userprincipalname}
Give permissions to:
$allmailbox =
Get-Mailbox -Resultsize
Unlimited -Filter
{RecipientTypeDetails -eq
‘Type_Of_Mailbox_You_Want’}
Foreach ($Mailbox
in $allmailbox)
{
   
$path =
$Mailbox.alias
+ “:”
+ (Get-MailboxFolderStatistics
$Mailbox.alias
| Where-Object
{ $_.Foldertype
-eq “Calendar”
} | Select-Object
-First 1).Name
   
set-mailboxfolderpermission –identity ($path)
–user Mail_Enabled_Security_Group
-Member –Accessrights
Right_You_Want_To_Add
Available permissions are:
Owner, PublishingEditor, Editor, PublishingAuthor, Author, NonEditingAuthor, Reviewer, Contributor, AvailabilityOnly, LimitedDetails

Available RecipientTypeDetails are:

UserMailbox, RoomMailbox, EquipmentMailbox

That all. Powershell rocks again 🙂

Author: Harri Jaakkonen

Leave a Reply

Your email address will not be published. Required fields are marked *