Skip to content

Instantly share code, notes, and snippets.

@bill-long
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bill-long/f97df51f2151afe5340f to your computer and use it in GitHub Desktop.
Save bill-long/f97df51f2151afe5340f to your computer and use it in GitHub Desktop.
Check PF hierarchy synchronization on Exchange 2013
# Check-HierarchySync.ps1
$allPFs = New-Object 'System.Collections.Generic.List[string]'
$PFsPerMbx = New-Object 'System.Collections.Generic.Dictionary[string, System.Collections.Generic.List[string]]'
$pfMailboxes = Get-Mailbox -PublicFolder
foreach ($pfMailbox in $pfMailboxes)
{
"Getting public folders from mailbox: " + $pfMailbox
$pfs = Get-PublicFolder -Recurse -Mailbox $pfMailbox.Identity | % { $_.Identity.ToString() }
$PFsPerMbx.Add($pfMailbox.Name, $pfs)
foreach ($pf in $pfs)
{
if (!$allPFs.Contains($pf))
{
$allPFs.Add($pf)
}
}
}
$allPFs.Sort()
foreach ($key in $PFsPerMbx.Keys)
{
$foldersMissing = New-Object 'System.Collections.Generic.List[string]'
$foldersMissing.AddRange($allPFs)
foreach ($pf in $PFsPerMbx[$key])
{
$foldersMissing.Remove($pf) | Out-Null
}
if ($foldersMissing.Count -gt 0)
{
"Folders missing in mailbox: " + $key
$foldersMissing
""
}
else
{
"No folders missing in mailbox: " + $key
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment