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
Foreach ($Mailbox
in $allmailbox)
$path =
+ “:”
+ (Get-MailboxFolderStatistics
| Where-Object
{ $_.Foldertype
-eq “Calendar”
} | Select-Object
-First 1).Name
set-mailboxfolderpermission –identity ($path)
–user Mail_Enabled_Security_Group
-Member –Accessrights
Available permissions are:
Owner, PublishingEditor, Editor, PublishingAuthor, Author, NonEditingAuthor, Reviewer, Contributor, AvailabilityOnly, LimitedDetails

Available RecipientTypeDetails are:

UserMailbox, RoomMailbox, EquipmentMailbox

That all. Powershell rocks again 🙂