Exchange 2007 or 2010 Public Folder report incl rights, email addresses and size

Because I couldn’t quickly find a good script/tool to make a report of my Public Folders that includes a complete drilldown including if they’re mail enabled, what email addresses it has, who has rights on the folder and what size the folders are, I’m sharing this script with you 🙂

Edit: added support for Exchange 2010, uncomment the correct section and comment the 2007 code if you run this on 2010.

#Copyright: Free to use, please leave this header intact
#Author: Jos Lieben (OGD)
#Company: OGD (
#Script help:
#Purpose: This script will give you an inventory of your public folders including usage

$csvPath = Read-Host "Type a full path for a CSV file if you wish to export to CSV, otherwise, press enter"
Write-Host "One moment please…." -ForeGroundColor Green
$publicfolders = get-publicfolder -recurse -Identity "\"
$totalSize = 0
$output = @()
Write-Progress -Activity "Gathering data...." -PercentComplete 0 -Status "0% klaar"
$totalToDo = $publicfolders.Count
$done = 0
Foreach($folder in $publicfolders){
$percent = ($done/($publicfolders.Count))*100
}catch{$percent = 0}

Write-Progress -Activity "Gegevens zoeken...." -PercentComplete $percent -Status "$percent% klaar - processing $($folder.Identity)"
$stringStart = $folder.Replicas[0].DistinguishedName.IndexOf("InformationStore,CN=")+20
$parseString = $folder.Replicas[0].DistinguishedName.SubString($stringStart)
$serverName = $parseString.SubString(0,$parseString.IndexOf(","))
#$serverName = $folder.OriginatingServer.domain
$stats = Get-PublicFolderStatistics -Server $serverName -Identity $folder.Identity
$totalSize += $($stats.TotalItemSize.Value.ToMB())
$obj = New-Object PSObject
$obj | Add-Member NoteProperty folder($folder.Identity)
$obj | Add-Member NoteProperty size($stats.TotalItemSize.Value.ToMB())
$obj | Add-Member NoteProperty LastAccessTime($stats.lastAccessTime)
$pfMailProperties = Get-MailPublicFolder -Identity $folder.Identity
$proxies = $pfMailProperties.EmailAddresses -Join ","
$obj | Add-Member NoteProperty mailEnabled("YES")
$obj | Add-Member NoteProperty emailAddresses($proxies)
$obj | Add-Member NoteProperty mailEnabled("NO")
$obj | Add-Member NoteProperty emailAddresses("NONE")
$perms = Get-PublicFolderClientPermission -Identity $folder.Identity -ErrorAction SilentlyContinue
$permColumn = 0
foreach($perm in $perms){
$obj | Add-Member NoteProperty username$permColumn($perm.User.ActiveDirectoryIdentity.Name)
$output += $obj
Write-Host "$($folder.Identity) failed to get info because of $($Error[0])" -ForeGroundColor Red

$output | Export-CVS -Path $csvPath -Delimiter ";"
Write-Output $output
Write-Host "Total size of all folders: $totalSize"

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Rafal Grzeda
Rafal Grzeda
3 years ago

My mistake, size is present.

Rafał Grzęda
Rafał Grzęda
3 years ago

Thank you. Nice, could be report size of folder. Small error Export-cvs change export-csv.


[…] course I had to try that out asap 🙂 I used an older script to make a report of my on prem public folders to pick one below […]