Calender Permissions
Hi
We are using Exchange 2010, and are trying to use the command shell to set calender permissions throughout the company.
User A should have editor access to ALL calenders throughout the company. I thought the below script would achieve this but its not working. It seems to only let User A see Free/Busy information and not actually see the full appointment details.
Can someone help?
#Custom variables
$mailboxes = Get-Mailbox -Database "Mailbox Database"
$AccessRights = "Editor"
#Loop through all mailboxes
foreach ($mailbox in $mailboxes) {
#Retrieve name of the user`s calendar
$calendar = (($mailbox.SamAccountName)+ ":\" + (Get-MailboxFolderStatistics -Identity $mailbox.SamAccountName -FolderScope Calendar | Select-Object -First 1).Name)
#Check if calendar-permission for user "UserA" is set to the default permission of "Editor"
if (((Get-MailboxFolderPermission $calendar | Where-Object {$_.User -like "UserA"}).AccessRights) -like "Editor" ) {
Write-Host "Updating calendar permission for $mailbox..." -ForegroundColor Yellow
#Set calendar-permission for user "UserA" to value defined in variable $AccessRights
Set-MailboxFolderPermission -User "UserA" -AccessRights $AccessRights -Identity $calendar
}
}
Any help on this is appreciated!
Thanks
Ben Weinberg
Prime-Networks
www.prime-networks.co.uk
Please post the resolution to your issue so that everyone can benefit
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
May 22nd, 2012 8:27am
It looks like your if then is not correct. It is saying If UserA has Editor, then add the rights, you need to change it to If NOT, like this:
if (!(((Get-MailboxFolderPermission $calendar | Where-Object {$_.User -like "UserA"}).AccessRights) -like "Editor" )) {
or:
if (((Get-MailboxFolderPermission $calendar | Where-Object {$_.User -like "UserA"}).AccessRights) -ne "Editor" ) {
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2012 10:47am
Russ
Thanks for the reply. This seems to be working a little better, but will only update existing permissions. On mailboxes where UserA doesn't have any permissions pre defined it fails with:
Updating calendar permission for UserB...
There is no existing permission entry found for user: UserA.
+ CategoryInfo : NotSpecified: (0:Int32) [Set-MailboxFolderPermission], UserNotFoundInPermissionEntryExce
ption
+ FullyQualifiedErrorId : C2046FC4,Microsoft.Exchange.Management.StoreTasks.SetMailboxFolderPermission
How can i stop that?
Ben Weinberg
Prime-Networks
www.prime-networks.co.uk
Please post the resolution to your issue so that everyone can benefit
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
May 22nd, 2012 11:11am
Hmm its ok
I just ran the script twice and on the second time changed:
set-MailboxFolderPermission -User "UserA" -AccessRights $AccessRights -Identity $calendar
to:
Add-MailboxFolderPermission -User "UserA" -AccessRights $AccessRights -Identity $calendar
Thanks for all your help!
Ben Weinberg
Prime-Networks
www.prime-networks.co.uk
Please post the resolution to your issue so that everyone can benefit
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2012 11:17am
Glad it resolved.
If you have any other question on this issue, please feel free to let me know.
Thanks,
Evan Liu
TechNet Subscriber Support in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com Evan Liu
TechNet Community Support
May 23rd, 2012 3:31am