Today I will be discussing how to add, and remove, contacts and calendars permissions for users of Office 365 by using PowerShell.
This can be useful should you have trouble trying to add permissions viaOutlook.
First you need to connect to the Office 365 Exchange Powershell
Open a PowerShell session and enter these commands, providing your Office 365 admin account details when requested:
$cred = Get-Credential
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic –AllowRedirection
Import-PSSession $session
Now you can get on with the adding and removing user permissions.
Check current permissions
Before you start adding permissions, check if there are any existing permissions on the folder first. If a user already has permissions for another user’s contacts/calendar folder then you won’t be able to change them until the permissions are removed. To do this, type in the following code:
Get-MailboxFolderPermission -Identity user@domain.com:\Calendar| Select User, AccessRights, Deny
Change user@domain.com to which ever user you want to view.
Also Calendar can be changed for Contacts if you want to view who has access to the contacts folder.
Add Permissions
Now that you know the permissions for the folder, you can start adding and removing. First we shall look at adding permissions. Before adding permissions for a user, decide which permission you would like to give them. Below are the options:
Owner
Create, read, modify, and delete all items and files, and create subfolders. As the folder owner, you can change the permission levels others have for the folder. (Does not apply to delegates.)
Publishing Editor
Create, read, modify, and delete all items and files, and create subfolders.
Editor
Create, read, modify, and delete all items and files.
Publishing Author
Create and read items and files, create subfolders, and modify and delete items and files you create.
Author
Create and read items and files, and modify and delete items and files you create.
Contributor
Create items and files only. The contents of the folder do not appear.
Reviewer
Read items and files only
Custom
Perform activities defined by the folder owner.
None
You have no permission’s. You can’t open the folder.
Once you’ve chosen the permissions you wish to give the user you can add the permissions using PowerShell.
Use the following code to do this:
Add-MailboxFolderPermission -Identity user@domain.com:\Calendar -AccessRights [Permission goes here] -User user2@domain.com
Replace the User@domain.com with the mailbox you want to add permissions to and user2@domain.com to the mailbox you want to have access. Also change [Permission goes here] to whatever permission you wish to use from the list above.
Remove Permissions
Lastly, if you want to remove some permissions then you can use this line of code:
Remove-MailboxFolderPermission -Identity user@domain.com:\Calendar -User user2@domain.com
if you receive the following error message "The Sharing policy doesn't allow you to grant certain permissions to users on...
Simply check out the users alias (user@tenant.onmicrosoft.com) and try replacing both users with the tenant alias names