PowerShell: Export All Exchange Mailbox Folder Permissions In A Format For Further Processing: Part 2

This is an update to my function to extract Mailbox folder permissions as PowerShell objects, allowing various forms of processing.

The main script is here.

In this update I’ve made the function skip some default folders it can’t process, treat the root of the mailbox better and improved the logging.

The first change was to add an array of folders to skip;

  [string[]]$FolderExclusions = @("/Sync Issues","/Sync Issues/Conflicts","/Sync Issues/Local Failures","/Sync Issues/Server Failures","/Recoverable Items","/Deletions","/Purges","/Versions")

In the previous versions these folders would generate errors as they’re special and can’t be read normally.

To use the exceptions the line where the folder names are retrieved is updated as follows;

  $FolderNames=$MailboxToProcess| Get-MailboxFolderStatistics | Where-Object {!($FolderExclusions -icontains $_.FolderPath)} |
 Select-Object -ExpandProperty FolderPath | ForEach-Object{$MailboxToProcess.DistinguishedName.ToString() +":"+($_ -replace ("/","\"))}

It just checks that $FolderExclusions doesn’t include the name of the folder being currently processed.  -icontains is a case-insensitive comparison.

  $FolderName=$FolderName -replace ("Top Of Information Store","")

This line ensures the root of the mailbox is processed correctly.  Get-MailboxFolderStatistics calls the root folder “Top Of Information Store” but Get-MailboxFolderStatistics just refers to it as “\”.  The above line removes the long name which just leaves the “\”.

Other than that, the Write-Verbose lines have all been cleared up so there should be better Verbose logging!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s