07 February 2017

How to bulk change Calendar permissions in Exchange 2013 using PowerShell

Let’s assume, that you want to let some group of users see each others calendars. Instead of instructing each user to change calendar permissions using Outlook, you can do it for them.

First lets try to see current permissions:

$users = Get-DistributionGroupMember groupname@contoso.com | select -ExpandProperty PrimarySmtpAddress
foreach ($user in $users)
{$folder = $user + ':\' + (Get-MailboxFolderStatistics $user | where foldertype -eq calendar).name
"------------------------------------------------------------------------------------------------"
$folder
Get-MailboxFolderPermission $folder
}


It will produce similar output:
image

To add permissions, you simply need to change the get cmdlet to add cmdlet:

$users = Get-DistributionGroupMember groupname@contoso.com | select -ExpandProperty PrimarySmtpAddress
foreach ($user in $users)
{$folder = $user + ':\' + (Get-MailboxFolderStatistics $user | where foldertype -eq calendar).name
"------------------------------------------------------------------------------------------------"
$folder

Add-MailboxFolderPermission $folder -User groupname@contoso.com -AccessRights reviewer
Set-MailboxFolderPermission $folder -User groupname@contoso.com -AccessRights reviewer
}

Add and Set are both present because if the permission is already present, then first command will fail. If you want to use default calendar permissions, the mailboxpermission cmdlets should have ‘-User Default’ in the middle. If you want to change calendar permissions on all users, then instead of get-distributiongroupmember you should use get-mailbox instead.

No comments:

Post a Comment