Get Calendar Permissions for All Users in Office 365

In Exchange, the calendar data is located in a special folder (Calendar) under the user’s mailbox. We can use the Exchange PowerShell cmdlet Get-MailboxFolderPermission to list all permissions that are configured in a Calendar folder.

Before you start, install the latest Exchange Online Management PowerShell module and run the below command to connect the Exchange Online (EXO V2) Powershell.

Connect-ExchangeOnline

Get permissions for a single user in a user’s calendar

The below command returns permission entries for an individual user in a specific user’s mailbox calendar. Run the below command after replacing the user “[email protected]” and mailbox identity “[email protected]” with your user id and mailbox id.

Get-MailboxFolderPermission -Identity "[email protected]:\Calendar" -User "[email protected]"

Get all permissions in a user’s calendar

You have to exclude the parameter “-User” to list all user permissions in a specific user’s mailbox. The below command list all users who have permission in Alex’s mailbox calendar.

Get-MailboxFolderPermission -Identity "[email protected]:\Calendar"

Get all permissions in all users calendar

To extract permissions from all users’ calendars, first, we have to fetch all mailboxes with the Get-Mailbox cmdlet and pipe the result to Get-MailboxFolderPermission cmdlet to get the mailbox folder permissions.

Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\Calendar" } | Select Identity,User,AccessRights

The above command returns all permission entries in all users’ calendar, the result also includes the default permissions “Default” & “Anonymous”. You can exclude the “Default” & “Anonymous” entries with Where-Object filter.

Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\Calendar" } | Where-Object {$_.User.DisplayName -ne "Default" -and $_.User.DisplayName -ne "Anonymous"} | Select Identity,User,AccessRights

Export all users calendar permissions in all mailboxes to CSV file

$Result=@()
$allMailboxes = Get-Mailbox -ResultSize Unlimited | Select-Object -Property Displayname,PrimarySMTPAddress
$totalMailboxes = $allMailboxes.Count
$i = 1 
$allMailboxes | ForEach-Object {
$mailbox = $_
Write-Progress -activity "Processing $($_.Displayname)" -status "$i out of $totalMailboxes completed"
$folderPerms = Get-MailboxFolderPermission -Identity "$($_.PrimarySMTPAddress):\Calendar"
$folderPerms | ForEach-Object {
$Result += New-Object PSObject -property @{ 
MailboxName = $mailbox.DisplayName
User = $_.User
Permissions = $_.AccessRights
}}
$i++
}
$Result | Select MailboxName, User, Permissions |
Export-CSV "C:\CalendarPermissions.CSV" -NoTypeInformation -Encoding UTF8

Advertisement

6 thoughts on “Get Calendar Permissions for All Users in Office 365”

  1. Thanks for this command! I got an error, but it looks like its just because a backslash is missing in after the semicolon or before “Calendar”.

    Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxFolderPermission -Identity “$($_.PrimarySMTPAddress):\Calendar” } | Select Identity,User,AccessRights

    Reply
  2. Hello,

    I changed it a bit to get the calendar permission regardless of the language.

    $Result=@()
    $allMailboxes = Get-Mailbox -ResultSize Unlimited | Select-Object -Property Displayname,PrimarySMTPAddress
    $totalMailboxes = $allMailboxes.Count
    $i = 1

    $allMailboxes | ForEach-Object {
    $mailbox = $_
    Write-Progress -activity “Processing $($_.Displayname)” -status “$i out of $totalMailboxes completed”
    $calendarFolder = Get-MailboxFolderStatistics -Identity $mailbox.PrimarySMTPAddress -FolderScope Calendar | Where-Object { $_.FolderType -eq ‘Calendar’} | Select-Object Name, FolderId
    $folderPerms = Get-MailboxFolderPermission -Identity “$($_.PrimarySMTPAddress):$($calendarFolder.FolderId)”
    $folderPerms | ForEach-Object {
    $Result += New-Object PSObject -property @{
    MailboxName = $mailbox.DisplayName
    User = $_.User
    Permissions = $_.AccessRights
    }
    }
    $i++
    }
    $Result | Select MailboxName, User, Permissions | Export-CSV “C:\temp\CalendarPermissions.CSV” -NoTypeInformation -Encoding UTF8 -Delimiter “;”

    Reply

Leave a Comment