Editing calendar permissions Office 365 with powershell

After adding a new user into Office 365, the user has to be allowed to read/write some shared calendars withing the organization.

First of all you will need to connect to Office 365

Add permission to the calendar

Add-MailboxFolderPermission calendar@company.com:\Calendar -User dude@company.com -AccessRights Author

Note: AccessRights can be: Owner, PublishingEditor, Editor, PublishingAuthor, Author, NonEditingAuthor, Reviewer, Contributor, AvailabilityOnly, LimitedDetails

Get permission for a specific users

Get-MailboxFolderPermission -Identity calendar@company.com:\Calendar -User dude@company.com

To remove permissions for a specific user:

Remove-MailboxFolderPermission -Identity calendar@company:\calendar -user dude@company.com

 

UPDATE:

What if you need to change the calendar permissions for all users within your organization?!

$allmailbox = Get-Mailbox -Resultsize Unlimited
 
Foreach ($Mailbox in $allmailbox)
{
    $path = $Mailbox.alias + ":\" + (Get-MailboxFolderStatistics $Mailbox.alias | Where-Object { $_.Foldertype -eq "Calendar" } | Select-Object -First 1).Name
    Set-mailboxfolderpermission –identity ($path) –user Default –Accessrights AvailabilityOnly
}

10 thoughts on “Editing calendar permissions Office 365 with powershell”

  1. Thanks for the detailed descriptions in this post. I was wondering if you would know if there was a way to give permissions to an Active Directory OU group instead of individual Users. We use a hybrid system with MS365 Online and On prem.

    1. Hi Kris,

      I haven’t tried, but this should work.

      $ou-users = Get-ADUser -Filter * -SearchBase “ou=testou,dc=iammred,dc=net”
      Foreach ($Mailbox in $ou-users)
      {
      $path = $Mailbox.alias + “:\” + (Get-MailboxFolderStatistics $Mailbox.alias | Where-Object { $_.Foldertype -eq “Calendar” } | Select-Object -First 1).Name
      Set-mailboxfolderpermission -identity ($path) -user Default -Accessrights AvailabilityOnly
      }

      Later edit: by “Active Directory OU” you meant “Distribution Group”? If so, then:

      $dg-users = Get-DistributionGroupMember -Identity “distribution-group@company.com”
      Foreach ($Mailbox in $dg-users)
      {
      $path = $Mailbox.alias + “:\” + (Get-MailboxFolderStatistics $Mailbox.alias | Where-Object { $_.Foldertype -eq “Calendar” } | Select-Object -First 1).Name
      Set-mailboxfolderpermission -identity ($path) -user Default -Accessrights AvailabilityOnly
      }

      More info here:

      http://blogs.technet.com/b/heyscriptingguy/archive/2012/10/30/powertip-single-line-powershell-command-to-list-all-users-in-an-ou.aspx
      https://technet.microsoft.com/en-us/library/aa996367(v=exchg.150).aspx

    2. I assume you run Azure AD Connect to sync between 365 and on prem, if so, the easiest way i have found to do this is to create a mail-enabled group directly in 365, add the members you want, and then set the group as author

      Just did this my self:

      PS C:\WINDOWS\system32> Add-MailboxFolderPermission singsing@xyz.se:\Kalender -User kalendrar@xyz.se -AccessRights Author

      FolderName User AccessRights
      ———- —- ————
      Kalender Kalendrar@xyz.se {Author}

      noteworthy is that the calendar might not be named in english if you have a site configured in another language as my customers calander folder was named \Kalender

  2. Hey thank for the help! I was wondering, after i changes the permissions to reviewer, how can everyone bring up all the calendars in there side bar selection in outlook? i.e. how can they view the calendars, without having to search for the owner?

    1. Hi, I got the same question as Spencer.

      If that’s not possible though, is there a command or script to list down all calendars, sub calendar each user has (if they’ve created or shared any), along with the sharing permissions set for each calendar.

      Thanks!

  3. Is there a way that we can give all users permissions to view details on each other’s calendar by default ? So they can see all calendars in their outlook by default and be able to see their appointment details? How do we accomplish that with powershell?

  4. Is there a way in 365 to stop the ability of a user requesting permissions to have access to another user’s calendar? We have users who go into someone else’s calendar and try to go into a meeting and it tells them they don’t have access, do you want to request access? The person clicks yes and then it brings up a form to send to the user they want access to, and you fill out some stuff and send it. We want to stop that kind of sharing from happening. Thanks!

  5. Great article, worked on first try.
    Not all heroes wears capes!

    Thanks a lot, now I’m interested to see what else you have in your portfolio :)

  6. Hi

    My PS script doesn’t seem to work – code below: It seems to have a problem with the $email.alias although there is a value stored in it.
    # Adds Exchange Management 2010 Snap-in #
    add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010;

    # Loads .NET Framework to allow use of VisualBasic Input Box #
    [System.Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’) | Out-Null

    # Shows message box and takes the assigns the value to the $email variable #
    $email = [Microsoft.VisualBasic.Interaction]::InputBox(“Enter an Email Address”, “User to run Action on”, “”)

    Get-mailbox -Identity $email

    ### TEST $EMAIL HAS A VALUE ###
    Write-Output $email

    # Shows message box and takes the assigns the value to the $folder variable #
    # $folder = [Microsoft.VisualBasic.Interaction]::InputBox(“Enter a Mailbox Folder”, “User to run Action on”, “This Is Case Sensitive”)

    # Get Permissions that the person entered has to mailboxes

    $path = $email.alias+”:\Calendar”

    ### TEST $PATH IS COMPLETE ###
    Write-output $path

    Get-MailboxFolderPermission -identity $path

    Does anyone have any ideas why it’s not working – the command Get-MailboxFolderPermission works fine if I manually give it a value (as opposed to a variable)

Leave a Reply

Your email address will not be published. Required fields are marked *