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.

########
#publicFolderReport
#Copyright: Free to use, please leave this header intact
#Author: Jos Lieben 
#Company: Lieben Consultancy
#Script help: http://www.liebensraum.nl
#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){
try{
$done++
$percent = ($done/($publicfolders.Count))*100
}catch{$percent = 0}
Try{

Write-Progress -Activity "Gegevens zoeken...." -PercentComplete $percent -Status "$percent% klaar - processing $($folder.Identity)"
#EXCHANGE 2007
$stringStart = $folder.Replicas[0].DistinguishedName.IndexOf("InformationStore,CN=")+20
$parseString = $folder.Replicas[0].DistinguishedName.SubString($stringStart)
$serverName = $parseString.SubString(0,$parseString.IndexOf(","))
#/EXCHANGE 2007
#EXCHANGE 2010
#$serverName = $folder.OriginatingServer.domain
#/EXCHANGE 2010
$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)
if($folder.MailEnabled){
$pfMailProperties = Get-MailPublicFolder -Identity $folder.Identity
$proxies = $pfMailProperties.EmailAddresses -Join ","
$obj | Add-Member NoteProperty mailEnabled("YES")
$obj | Add-Member NoteProperty emailAddresses($proxies)
}else{
$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){
if($perm.User.ActiveDirectoryIdentity.Name){
$obj | Add-Member NoteProperty username$permColumn($perm.User.ActiveDirectoryIdentity.Name)
$permColumn++
}
}
$output += $obj
}catch{
Write-Host "$($folder.Identity) failed to get info because of $($Error[0])" -ForeGroundColor Red
}
}

if($csvPath){
$output | Export-CSV -Path $csvPath -Delimiter ";"
}else{
Write-Output $output
}
Write-Host "Total size of all folders: $totalSize"
Subscribe
Notify of
guest

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

5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Chris
Chris
1 year ago

Thanks, worked great. FYI Export-CSV is typo’d, easy fix.

Rafal Grzeda
Rafal Grzeda
4 years ago

My mistake, size is present.

Rafał Grzęda
Rafał Grzęda
4 years ago

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

trackback

[…] 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 […]