You like to remove a certificate in Exchange Server. After signing in to Exchange Admin…
Export mailbox folder permissions to CSV file
In a previous article, we discussed how to export mailbox permissions to CSV file. This time, we want to export mailbox folder permissions to CSV file. We like to know which user has access to which folder and which permission level access they have to that folder. We will look into the mailbox folder permissions of a single user and all the users. In this article, you will learn how to export mailbox folder permissions to CSV file.
Introduction
To let you understand what permissions are being exported, it’s better to have an example. Start Outlook and sign in as a user. In our case, it’s the user James.
Outlook Today (Top of Information Store) folder permissions
Right-click on the email address in the left sidebar and select Folder Permissions. That is the Outlook Today (Top of Information Store).
We can see that the permission level Publishing Author is given to the user Anna.
Inbox folder permissions
Right-click the Inbox folder and click Properties.
Click the Permissions tab. The permission level Reviewer is given to the user Boris.
Management subfolder permissions
Right-click the Inbox folder and create a new folder. Name the subfolder Management. Right-click the created subfolder and click Properties.
Click on the Permissions tab. You can see that it’s inheriting the permissions from the parent folder. That’s because we created the subfolder after we configured the permissions. In our case, it’s the Inbox folder.
Add another user to the Management folder and give the permission level Contributor. In our example, Hannah is given the permissions level Contributor.
Sales subfolder permissions
Create one more subfolder. We are creating a subfolder with the name Sales. We don’t want to give permissions to that subfolder.
Note: The subfolder permissions are inherited from the parent folder if you create a new subfolder. The subfolder will look at the permissions of the parent folder. If you add permissions to the parent folder after you create the subfolder, the permissions of the subfolder will not inherit.
Right-click the Sales folder and click Properties.
Go to the Permissions tab. Remove the user Boris from permissions and click Apply. The names Default and Anonymous with permission level None are the default. Keep it like that.
We configured the following permissions on the folders:
- Outlook Today (Top of Information Store) – Publishing Author – Anna
- Inbox – Reviewer – Boris
- Management – Reviewer – Boris
- Management – Contributor – Hannah
- Sales – Default
In the next step, we will look into the mailbox folder permissions PowerShell script.
Export mailbox folder permissions PowerShell script
Download the Get-MailboxPermissionsReport.ps1 PowerShell and save the file in the C:\scripts folder. If you don’t have a scripts folder, create one.
Ensure the file is unblocked to prevent errors when running the script. Read more in the article Not digitally signed error when running PowerShell script.
Another option is to copy and paste the below code into Notepad. Give it the name Get-MailboxPermissionsReport.ps1 and place it in the C:\scripts folder.
<#
.SYNOPSIS
Get-MailboxPermissionsReport.ps1
.DESCRIPTION
The script will export all mailbox folder permissions to CSV file.
.LINK
www.alitajran.com/export-mailbox-folder-permissions-to-csv-file/
.NOTES
Written by: ALI TAJRAN
Website: www.alitajran.com
LinkedIn: linkedin.com/in/alitajran
.CHANGELOG
V1.00, 01/08/2020 - Initial version
#>
param (
[string]$Identity = "*", # Default value is "*" (all users)
[string]$OutputFile = "C:\temp\MailboxPermissions.csv"
)
# Fetch mailboxes of type UserMailbox only
$Mailboxes = Get-Mailbox -RecipientTypeDetails 'UserMailbox' $Identity -ResultSize Unlimited | Sort-Object
$result = @()
# Counter for progress bar
$MailboxCount = ($Mailboxes | Measure-Object).Count
$count = 1
foreach ($Mailbox in $Mailboxes) {
# Use Alias property instead of name to ensure 'uniqueness' passed on to Get-MailboxFolderStatistics
$Alias = '' + $Mailbox.Alias
$DisplayName = ('{0} ({1})' -f $Mailbox.DisplayName, $Mailbox.Name)
$activity = ('Working... [{0}/{1}]' -f $count, $MailboxCount)
$status = ('Getting folders for mailbox: {0}' -f $DisplayName)
Write-Progress -Status $status -Activity $activity -PercentComplete (($count / $MailboxCount) * 100)
# Fetch folders
$Folders = @('\')
$FolderStats = Get-MailboxFolderStatistics $Alias | Select-Object -Skip 1
foreach ($FolderStat in $FolderStats) {
$FolderPath = $FolderStat.FolderPath.Replace('/', '\')
$Folders += $FolderPath
}
foreach ($Folder in $Folders) {
# Build folder key to fetch mailbox folder permissions
$FolderKey = $Alias + ':' + $Folder
# Fetch mailbox folder permissions
$Permissions = Get-MailboxFolderPermission -Identity $FolderKey -ErrorAction SilentlyContinue
# Store results in variable
foreach ($Permission in $Permissions) {
$User = $Permission.User -replace "ExchangePublishedUser\.", ""
if ($User -notlike 'Default' -and
$User -notlike 'Anonymous' -and
$Permission.AccessRights -notlike 'None' -and
$Permission.AccessRights -notlike 'Owner') {
$result += [PSCustomObject]@{
Mailbox = $DisplayName
FolderName = $Permission.FolderName
Identity = $Folder
User = $User -join ','
AccessRights = $Permission.AccessRights -join ','
}
}
}
}
# Increment counter
$count++
}
# Export to CSV
$result | Export-Csv -Path $OutputFile -NoTypeInformation -Encoding UTF8 -Delimiter ';'
This is how it looks in File Explorer.
The Get-MailboxPermissionsReport.ps1 PowerShell script does have the following options for exporting the permissions:
- Option 1: Export mailbox folder permissions of a single user
- Option 2: Export mailbox folder permissions of users that start or end with a given name
- Option 3: Export mailbox folder permissions of the entire organization
Let’s have a look at the options in the next step.
Option 1: Export mailbox folder permissions of a single user
Run Exchange Management Shell as administrator.
Get specific mailbox folder permissions of a user. Fill in the display name or email address of the user mailbox. The exported CSV file will be in the same place as the script with the name MailboxPermissions_Single_User.csv.
C:\scripts\.\Get-MailboxPermissionsReport.ps1 -Identity "James.Paterson@exoip.com" -OutputFile "MailboxPermissions_Single_User.csv"
After running the above command, go to the scripts folder. Open the CSV file with the application Notepad.
Open the CSV file with your favorite CSV file editor. For example, Microsoft Excel.
What you can see is that you don’t see the Sales folder in the list. That’s because the folder does not have any permissions configured.
Note: If there are no permissions configured on the folders, the folders will not be exported to the CSV file.
Option 2: Export mailbox folder permissions of users that start or end with a given name
This will look at the mailboxes starting with the name James. If you want to search mailboxes that end with a name, change the * to the front of the name. It will look like “*James” instead of “James*”.
The CSV file export will be in the same place where the script was started with the name MailboxPermissions_Multi_User.csv.
C:\scripts\.\Get-MailboxPermissionsReport.ps1 -Identity "James*" -OutputFile "MailboxPermissions_Multi_User.csv"
In the next step, we will get every user mailbox folder permissions in the organization and export it to a CSV file. It can take time if you have a large organization.
Option 3: Export mailbox folder permissions of the entire organization
Get all the mailbox folder permissions in the Exchange organization. This will export the mailbox folder permissions of all the user mailboxes in the Exchange organization to the file MailboxPermissions_All_Users.csv.
C:\scripts\.\Get-MailboxPermissionsReport.ps1 -OutputFile "MailboxPermissions_All_Users.csv"
Open the CSV file. We can see the mailbox folder permissions of all the user mailboxes in the organization.
Did this help you to get the mailbox folder permissions in Exchange Server and export it to a CSV file?
Read more: Create Active Directory Users from CSV with PowerShell »
Conclusion
You learned how to export mailbox folder permissions to CSV file. Make use of the Get-MailboxPermissionsReport.ps1 PowerShell script. Run the script to generate a CSV file with the mailbox permissions. Go to the location and open the CSV file with your favorite CSV file editor. Have a look at which mailbox folder permissions are configured.
Did you enjoy this article? You may also like Add email address to list of names in Excel. Don’t forget to follow us and share this article.
This Post Has 0 Comments