Office 365 PowerShell: How to bulk change Office 365 calendar permissions using Windows PowerShell

office365 powershell

I recently had to make some bulk changes to calendar permissions in Office 365, the client wanted the Default user permission to be set to Reviewer rather than AvailabilityOnly. So in this post I’ll walk you through how I went about making bulk permission changes to the Default user for the calendar folder for all users in Office 365.

1. Sign into Office 365 PowerShell, I’ve already blogged about how to do this, so follow the instructions at this link: How to connect to and manage Office365 using PowerShell

2. Once connected to PowerShell, let’s start by seeing how many mailboxes we are dealing with.

Type Get-Mailbox to list current mailboxes.

Get-Mailbox

So we are working with about 30 mailboxes.




3.Next let’s take a look at the calendar permissions on one of the mailboxes.

Type Get-MailboxFolderPermission username:\calendar

Get-MailboxFolderPermissions user-calendar

So you can see the Default user permission is currently set to AvailabilityOnly.

Now let’s combine the two commands and check the Calendar permissions for each user.

4. Type  Get-Mailbox | ForEach-Object {Get-MailboxFolderPermission $_”:\calendar”} | Select Identity, FolderName, User, AccessRights

get-mailbox pipe foreach-object get-mailboxfolderpermission calendar pipe select identity foldername user accessrights

Here we piped the Get-Mailbox cmdlet to the Get-MailboxFolderPermission cmdlet and using $_ are able to check the calendar folder for each mailbox. By using the Select cmdlet, I am able to include the Identity field. If you look at the image in part three above the default fields are FolderName, User, and AccessRights. You can run the command Get-MailboxFolderPermission username:\calendar | Format-List to view available fields.

5. This is good as it is showing us all the calendar permissions, but let’s refine the search using Where cmdlet so we only retrieve the results for Default user.

Type Get-Mailbox | ForEach-Object {Get-MailboxFolderPermission $_”:\calendar”} | Where {$_.User -like “Default”} | Select Identity, FolderName, User, AccessRights

get-mailbox pipe foreach-object get-mailboxfolderpermission calendar pipe where user like default pipe select identity foldername user accessrights

So out of all the accounts there are only 5 mailboxes that need the permissions changed, the rest have already been done. We also have a couple of mailboxes where the calendar folder can’t be found. We’ll ignore these as they are outside the scope of this article.

6. Now let’s change the Default user permission for the calendar folder. Instead of using Get-MailboxFolderPermission to check the permissions, we’ll use Set-MailboxFolderPermission to modify the existing permission. If you want to give a new user permissions to a calendar you would use Add-MailboxFolderPermission.

Type Get-Mailbox | ForEach-Object {Set-MailboxFolderPermission $_”:\calendar” -User Default -AccessRights Reviewer}

get-mailbox pipe foreach-obect set-mailboxfolderpermission calendar user default accessrights reviewer

As you can see the output of the command shows us any errors and warnings.





7. Now let’s check the permissions are correct. We’ll use the same command as in step 5.

Type Get-Mailbox | ForEach-Object {Get-MailboxFolderPermission $_”:\calendar”} | Where {$_.User -like “Default”} | Select Identity, FolderName, User, AccessRights

get-mailbox pipe foreach-object get-mailboxfolderpermission calendar pipe where user like default pipe select identity foldername user accessrights after changes

So the end result is all users have the Default user permission of their calendar folder set to Reveiwer.

Resources:

Get-Mailbox

Get-MailboxFolderPermission

ForEach-Object

Select-Object

Where-Object

 

Related Posts:

1. How to connect to and manage Office365 using PowerShell

2. Office365 PowerShell: How to the find out mailbox sizes in Office365 (and Exchange 2016) using PowerShell

3. Exchange 2013 Initial Configuration Settings

4. How to install Exchange 2013 (SP1) on Windows Server 2012 R2




If you found this post useful, please share!

    Related Posts

    Leave a Reply

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