├── Get-MailboxPermissionReport.ps1 ├── LICENSE.md └── README.md /Get-MailboxPermissionReport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Dump mailbox folder permissions to CSV file 4 | 5 | Thomas Stensitzki 6 | 7 | THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE 8 | RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER. 9 | 10 | Version 1.4, 2019-06-14 11 | 12 | Ideas, comments and suggestions to support@granikos.eu 13 | 14 | This script is based on Mr Tony Redmonds blog post http://thoughtsofanidlemind.com/2014/09/05/reporting-delegate-access-to-exchange-mailboxes/ 15 | 16 | .LINK 17 | http://www.granikos.eu/en/scripts 18 | 19 | .DESCRIPTION 20 | This script exports all mailbox folder permissions for mailboxes of type "UserMailbox". 21 | 22 | The permissions are exported to a local CSV file 23 | 24 | The script is inteded to run from within an active Exchange 2013 Management Shell session. 25 | 26 | .NOTES 27 | Requirements 28 | - Windows Server 2012 or newer 29 | - Exchange Server Management Shell (EMS) 2010+ 30 | 31 | Revision History 32 | -------------------------------------------------------------------------------- 33 | 1.0 | Initial community release 34 | 1.1 | Minor PowerShell fix 35 | 1.2 | Minor PowerShell changes 36 | 1.3 | MailboxId parameter 37 | 1.4 | Fix to ensure mailbox uniqueness using the alias property 38 | 39 | .PARAMETER MailboxId 40 | Mailbox filter, default * 41 | 42 | .PARAMETER CsvFileName 43 | CSV file name, default MailboxPermissions.csv 44 | 45 | .EXAMPLE 46 | Export mailbox permissions to export.csv 47 | 48 | .\Get-MailboxPermissionsReport-ps1 -CsvFileName export.csv 49 | 50 | #> 51 | [CmdletBinding()] 52 | Param( 53 | [string]$MailboxId = '*', 54 | [string]$CsvFileName = 'MailboxPermissions.csv' 55 | 56 | ) 57 | 58 | $ScriptDir = Split-Path -Path $script:MyInvocation.MyCommand.Path 59 | $ScriptName = $MyInvocation.MyCommand.Name 60 | 61 | # build CSV full path to store CSV in script directory 62 | $OutputFile = Join-Path -Path $ScriptDir -ChildPath $CsvFileName 63 | 64 | Write-Verbose -Message $OutputFile 65 | 66 | # Fetch mailboxes of type UserMailbox only 67 | $Mailboxes = Get-Mailbox -RecipientTypeDetails 'UserMailbox' -Identity $MailboxId -ResultSize Unlimited | Sort-Object 68 | 69 | $result = @() 70 | 71 | # counter for progress bar 72 | $MailboxCount = ($Mailboxes | Measure-Object).Count 73 | $count = 1 74 | 75 | ForEach ($Mailbox in $Mailboxes) { 76 | 77 | $Alias = '' + $Mailbox.Alias # Use Alias property instead of name to ensure 'uniqueness' passed on to Get-MailboxFolderStatistics 78 | 79 | $DisplayName = ('{0} ({1})' -f $Mailbox.DisplayName, $Mailbox.Name) 80 | 81 | $activity = ('Working... [{0}/{1}]' -f $count, $mailboxCount) 82 | $status = ('Getting folders for mailbox: {0}' -f $DisplayName) 83 | Write-Progress -Status $status -Activity $activity -PercentComplete (($count/$MailboxCount)*100) 84 | 85 | # Fetch folders 86 | $Folders = @('\') 87 | $Folders += Get-MailboxFolderStatistics $Alias | Select-Object -Skip 1 | ForEach-Object {$_.folderpath} | ForEach-Object{$_.replace('/','\')} 88 | 89 | ForEach ($Folder in $Folders) { 90 | 91 | # build folder key to fetch mailbox folder permissions 92 | $FolderKey = $Alias + ':' + $Folder 93 | 94 | # fetch mailbox folder permissions 95 | $Permissions = Get-MailboxFolderPermission -Identity $FolderKey -ErrorAction SilentlyContinue 96 | 97 | # store results in variable 98 | $result += $Permissions | Where-Object {$_.User -notlike 'Default' -and $_.User -notlike 'Anonymous' -and $_.AccessRights -notlike 'None' -and $_.AccessRights -notlike 'Owner' } | Select-Object -Property @{name='Mailbox';expression={$DisplayName}}, FolderName, @{name='Identity';expression={$Folder}}, @{name='User';expression={$_.User -join ','}}, @{name='AccessRights';expression={$_.AccessRights -join ','}} 99 | } 100 | 101 | # Increment counter 102 | $count++ 103 | } 104 | 105 | # Export to CSV 106 | $result | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8 -Delimiter ';' -Force 107 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Thomas Stensitzki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Get-MailboxPermissionReport.ps1 2 | 3 | Dump mailbox folder permissions to CSV file 4 | 5 | ## Description 6 | 7 | This script exports all mailbox folder permissions for mailboxes of type "UserMailbox". 8 | 9 | The permissions are exported to a local CSV file. 10 | 11 | The script is intended to run from within an active Exchange 2013 Management Shell session. 12 | 13 | ## Parameters 14 | 15 | ### MailboxId 16 | 17 | The mailbox id for filtering mailboxes, default * 18 | 19 | ### CsvFileName 20 | 21 | The file name for the export CSV file, default MailboxPermissions.csv 22 | 23 | ## Examples 24 | 25 | ``` PowerShell 26 | .\Get-MailboxPermissionsReport-ps1 -MailboxId "John*" -CsvFileName export.csv 27 | ``` 28 | 29 | Export permissions of all mailboxes starting with "John*" to file export.csv 30 | 31 | ## Note 32 | 33 | THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE 34 | RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER. 35 | 36 | ## Credits 37 | 38 | Written by: Thomas Stensitzki 39 | 40 | ## Stay connected 41 | 42 | - My Blog: [http://justcantgetenough.granikos.eu](http://justcantgetenough.granikos.eu) 43 | - Twitter: [https://twitter.com/stensitzki](https://twitter.com/stensitzki) 44 | - LinkedIn: [http://de.linkedin.com/in/thomasstensitzki](http://de.linkedin.com/in/thomasstensitzki) 45 | - Github: [https://github.com/Apoc70](https://github.com/Apoc70) 46 | - MVP Blog: [https://blogs.msmvps.com/thomastechtalk/](https://blogs.msmvps.com/thomastechtalk/) 47 | - Tech Talk YouTube Channel (DE): [http://techtalk.granikos.eu](http://techtalk.granikos.eu) 48 | 49 | For more Office 365, Cloud Security, and Exchange Server stuff checkout services provided by Granikos 50 | 51 | - Blog: [http://blog.granikos.eu](http://blog.granikos.eu) 52 | - Website: [https://www.granikos.eu/en/](https://www.granikos.eu/en/) 53 | - Twitter: [https://twitter.com/granikos_de](https://twitter.com/granikos_de) 54 | 55 | ## Additional Credits 56 | 57 | * This script is based on Mr Tony Redmonds blog post [http://thoughtsofanidlemind.com/2014/09/05/reporting-delegate-access-to-exchange-mailboxes](http://thoughtsofanidlemind.com/2014/09/05/reporting-delegate-access-to-exchange-mailboxes) --------------------------------------------------------------------------------