Last active
August 29, 2015 14:16
-
-
Save bill-long/f97df51f2151afe5340f to your computer and use it in GitHub Desktop.
Check PF hierarchy synchronization on Exchange 2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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