Link to home
Start Free TrialLog in
Avatar of mattclarified
mattclarifiedFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Set calendar permissions using Attributes in Exchange 2010 Powershell

Hi

I have recently set all the attributes for our company within AD, and want to set the calendar permissions for all users within one department to be able to access each others calendars.

eg.

If Department Attribute = "HR"
          set calendar permissions for HR group to Full

Any help is appreciated

M@
Avatar of soostibi
soostibi
Flag of Hungary image

Try this, customize the value of $group in first line.
$group = "yourdomain\HR"

$mbxs = Get-User -RecipientTypeDetails usermailbox | ?{$_.department -eq "HR"}| Get-Mailbox 

$mbxs | %{
    $smtp = $_.primarysmtpaddress.tostring() 
    $folder = $_ | Get-MailboxFolderStatistics  -FolderScope calendar | Select-Object -ExpandProperty name 
    Add-MailboxFolderPermission -Identity "$($smtp):\$folder" -AccessRights owner -User $group
}

Open in new window

SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A bit more optimised solution is below. The main difference between Chris' solution and mine, is that my works also in an international environment, where the folder Calendar has name in a different language.
$group = "yourdomain\HR"  

$mbxs = Get-User -RecipientTypeDetails usermailbox -Filter {department -eq "HR"} | Get-Mailbox 

$mbxs | %{
    $folder = $_ | Get-MailboxFolderStatistics  -FolderScope calendar | Select-Object -ExpandProperty name 
    Add-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\$folder" -AccessRights owner -User $group}

Open in new window

Avatar of mattclarified

ASKER

Thanks for your input both, I have run the following which seems to change the permissions on my calendar but not on any others in the group

get-user -filter { Department -eq "Department" } -RecipientType UserMailbox | ForEach-Object {
Set-MailboxFolderPermission "$($_.PrimarySmtpAddress):\Calendar" -User manager@company.com -AccessRights Reviewer }

I am testing it with one user getting access first before I start using groups, any ideas?

Thanks
M@
Is this returning the right number of users?

get-user -filter { Department -eq "Department" } -RecipientType UserMailbox

I think you'll want Add- instead of Set- for the permission as well. I think Set- will only modify the right if it's already there.

Chris
Thanks Chris, running the above command lists all the users within the specific Department.   I tried using add and it says that the permission already exists, it still seems to me that its trying to set it on my own account over and over.

M@
soos, when i try to run your version it returns

A parameter cannot be found that matches parameter name 'Identity'.

M@
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks soos, took it exactly as you had written it there, think it may have been because i was chopping your expert work up, should of listened to you in the first place!
Some points for Chris too for helping

Thanks for your help!

M@