Zachary Loeber

The personal website of Zachary Loeber.

Update: Get-CalendarPermission

Going through older code is a bit like looking through an old yearbook or photo album. If the pictures within are old enough you usually end up laughing at how little you recognize yourself and maybe even marvel a bit at how far you have come. This old function I wrote isn’t the worst of my code but I was still able to update it for measurable improvements.

The previous script accepted only strings and performed get-mailbox against it. This version will take a mailbox object from the pipe as well as take a string. This should speed up results in some cases and is far easier to use inline. Here is a quick example getting all the non-standard calendar permissions for all mailboxes and exporting to csv:

get-mailbox | get-calendarpermission | where {@('anonymous','default') -notcontains $_.User} | export-csv -notypeinformation explicitcalendarperms.csv

Here is the function in its entirety.

function Get-CalendarPermission {
    Retrieves a list of mailbox calendar permissions
    Get-CalendarPermission uses the exchange 2010 snappin to get a list of permissions for mailboxes in an exchange environment.
    As different languages spell calendar differently this script first pulls the actual name of the calendar by using
    get-mailboxfolderstatistics and has proven to work across multi-lingual organizations.
    .PARAMETER Mailbox
    One or more mailbox names.
    Last edit   :   09/24/2014
    Version     :   1.2.1 09/21/2014
                        - Removed log to file options and fixed a bunch of other issues.
                        - Enabled input of mailbox objects as well as strings
                    1.2.0 May 6 2013    :   Fixed issue where a mailbox name produces more than one mailbox
                    1.1.0 April 24 2013 :   Used new script template from
                    1.0.0 March 10 2013 :   Created script
    Author      :   Zachary Loeber

    Get-CalendarPermission -MailboxName "Test User1" -Verbose

    Gets the calendar permissions for "Test User1" and shows verbose information.

    Get-CalendarPermission -MailboxName "user1","user2" | Format-List

    Gets the calendar permissions for "user1" and "user2" and returns the info as a format-list.

    (Get-Mailbox -Database "MDB1") | Get-CalendarPermission | Format-Table Mailbox,User,Permission

    Gets all mailboxes in the MDB1 database and pipes it to Get-CalendarPermission. Get-CalendarPermission and returns the info as an autosized format-table containing the Mailbox,User, and Permission
        [Parameter(ParameterSetName='AsString', Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage="Enter an Exchange mailbox name")]
        [Parameter(ParameterSetName='AsMailbox', Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage="Enter an Exchange mailbox name")]
    begin {
        $Mailboxes = @()
    process {
        switch ($PSCmdlet.ParameterSetName) {
            'AsString' {
                try { 
                    $Mboxes = @(Get-Mailbox $MailboxName -erroraction Stop)
                    $Mailboxes += $Mboxes
                catch {
                    Write-Warning = "Get-CalendarPermission: $_.Exception.Message"
            'AsMailbox' {
               $Mailboxes += $MailboxObject
    end {
        foreach($Mailbox in $Mailboxes)
            # Construct the full path to the calendar folder regardless of the language
            $Calfolder = $Mailbox.Name + ':\' + [string](Get-MailboxFolderStatistics $Mailbox.Identity -folderscope calendar).Name
            # Get the permissions on the calendar
            $CalPerm = Get-MailboxFolderPermission $Calfolder
            $Results = @()
            foreach ($Perm in $CalPerm)
                $Results += New-Object PSObject -Property @{

This function has been uploaded to technet as well.

comments powered by Disqus