PowerShell Script: Public Folder Data to HTML

This script will help you inventory your Public Folder data to help you remove stale data saving backup cycles and recovering storage space.  You can see more details about this script in the accompanying blog post here.

Download the complete PS1 here:  publicFolderDataToHTML.ps1 (2.24 kb)

The areas highlighted in red are the attributes which can be changed.

C:\reports.htm – Is the location where the file will be created. You can change the file location to anywhere you want to just be aware that you need to make the change in the code in a multitude of locations.

c:\sorttable.js – Change the location of the js script that you downloaded

$server – Enter the name of the Public Folder you want to sort against

$folder = enter the root folder name where you want the script to start at. The script will start at the root folder and look at any subfolders

1/1/2000 12:00:00 AM - You will want to change this date for your environment. Changing the data will change which table a Public Folder will be placed in.

Copy the code from the box below and save it as a PS1 file.

Get-Date | Select-Object Date | convertTo-HTML -head $a -Title "Public Folder Access" | Out-File c:\report.htm

$server = "mailbox server name"

$folder = "\HR"

$a= "<script src=c:\sorttable.js type=text/javascript></script>"

$a = $a + "<style>"

$a = $a + "BODY{background-color:gray;}"

$a = $a + "TABLE.sortable thead {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"

$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:yellow}"

$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white}"

$a = $a + "</style>"

Get-PublicFolderStatistics -Server $server| Select-Object admindisplayname, creationtime, Lastmodificationtime, itemcount, totalitemsize, servername | where-object {$_.Lastmodificationtime -lt "1/1/2000 12:00:00 AM"} | convertTo-HTML  -Body "<H2>Over the last modified date</H2>"   |  Out-File c:\report.htm -append

Get-PublicFolderStatistics -Server $server| Select-Object admindisplayname, creationtime, Lastmodificationtime, itemcount, totalitemsize, servername | where-object {$_.Lastmodificationtime -gt "1/1/2000 12:00:00 AM"} | convertTo-HTML  -Body "<H2>Under the last modified date</H2>" |  Out-File c:\report.htm -append

Get-PublicFolder -Recurse -Server $server -Identity $folder | Select-Object Name, MailEnabled, HasSubFolders, IssueWarningQuota, MaxItemSize  | convertTo-HTML -head $a -Title "Public Folder Access" -Body "<H2>Public Folder Information</H2>" |  Out-File c:\report.htm -append

(Get-Content C:\report.htm) | Foreach-Object {$_ -replace "<table>", "<table class =sortable>"} | Set-Content C:\report.htm

(Get-Content C:\report.htm) | Foreach-Object {if($_ -like "*TotalItemSize*"){$_ -replace "t</th><th>", "t</th><th class=sorttable_numeric>"} else{$_}} | Set-Content C:\report.htm

(Get-Content C:\report.htm) | Foreach-Object {if($_ -like "*ItemCount*"){$_ -replace "ModificationTime</th><th>", "ModificationTime</th><th class=sorttable_numeric>"} else{$_}} | Set-Content C:\report.htm

(Get-Content C:\report.htm) | Foreach-Object {if($_ -like "*TotalItemSize*"){$_ -replace "count</th><th>", "count</th><th class=sorttable_numeric>"} else{$_}} | Set-Content C:\report.htm

Happy Exchanging!!!

Powered by BlogEngine.NET 1.5.0.7 | Log in

Calendar

<<  June 2013  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar