none
How to remove calendar permissions for all users in OU RRS feed

  • Question

  • Hi

    I need to remove all calendar permissions configured on user mailboxes in a specific OU. Only permissions left should be Default and Anonymous, and the Default should be set to Reviewer.

    The setting of the Deafult permissions I know how to do in a separate command, but I can't seem to get my head around the first one where I remove all current permissions on the calendar folder in all user mailboxes in the specified OU.

    So far I've got this :) Can anyone please help me finish this? Or perhaps if there is an easier way to do it then please help me with that one :)

    Get-Mailbox -RecipientTypeDetails UserMailbox | ? {$_.OrganizationalUnit -eq "domain.local/OU/SUB_OU"} 

    Best

    Thomas

    Tuesday, February 19, 2019 11:48 AM

Answers

  • Here you go:-

    $Mailboxes = get-mailbox -organizationalunit testlab.com/IT
    ForEach ($mbx in $Mailboxes)
    {
    Get-MailboxFolderPermission "${mbx}:\Calendar" | remove-mailboxfolderpermission -confirm:$false
    Add-MailboxFolderPermission "${mbx}:\Calendar" -User Default -AccessRights reviewer
    ADD-MailboxFolderPermission "${mbx}:\Calendar" -User Anonymous -AccessRights reviewer
    }
    Modify OU and rights as per your requirement.

    Note:- I always recommend to test any script in test lab first.


    Thanks,

    Ashish

    MCITP, MCT, MCSE

    “Tell me and I forget, teach me and I may remember, involve me and I learn.”

    Note:- Please remember to vote and mark the replies as answers if they help.

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees and confers no rights.


    Tuesday, February 19, 2019 5:29 PM

All replies

  • You're going to have a lot of trouble doing this on a single command line.  You're going to have to enumerate all the rights on all the mailboxes and remove the ones you don't want there, so you're looking at a nested loop of several commands.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    Tuesday, February 19, 2019 4:32 PM
    Moderator
  • yes

     ...You're going to have to enumerate all the rights on all the mailboxes and remove the ones you don't want there, so you're looking at a nested loop of several commands

    get-mailbox ..... | remove-mailboxfolderpermission "xyz:\calendar" -user -accessright


    Chris

    Tuesday, February 19, 2019 4:56 PM
  • Here you go:-

    $Mailboxes = get-mailbox -organizationalunit testlab.com/IT
    ForEach ($mbx in $Mailboxes)
    {
    Get-MailboxFolderPermission "${mbx}:\Calendar" | remove-mailboxfolderpermission -confirm:$false
    Add-MailboxFolderPermission "${mbx}:\Calendar" -User Default -AccessRights reviewer
    ADD-MailboxFolderPermission "${mbx}:\Calendar" -User Anonymous -AccessRights reviewer
    }
    Modify OU and rights as per your requirement.

    Note:- I always recommend to test any script in test lab first.


    Thanks,

    Ashish

    MCITP, MCT, MCSE

    “Tell me and I forget, teach me and I may remember, involve me and I learn.”

    Note:- Please remember to vote and mark the replies as answers if they help.

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees and confers no rights.


    Tuesday, February 19, 2019 5:29 PM
  • Soooh easy, if just I had the PS knowledge :)

    Just had to add the -RecipientTypeDetails UserMailbox and I had my command :)

    Super many thanks Ashish :)


    Wednesday, February 20, 2019 8:33 AM