Created
January 12, 2018 19:50
-
-
Save bill-long/f8f16f4e8fc6ef443a4430fe25b89b77 to your computer and use it in GitHub Desktop.
When performing New-MailboxRestoreRequest against a PF mailbox, public folders that don't exist in the hierarchy do not get created automatically. The report shows the missing folders. This script uses that report to recreate the hierarchy, so that the restore succeeds on the second attempt.
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
# Make sure the report is in the $report variable. Then just copy and paste this into Exchange Management Shell. | |
$report.Report.MailboxVerification | WHERE { $_.FolderIsMissing } | % { | |
$path = $_.FolderSourcePath | |
if (!($path.StartsWith("/IPM_SUBTREE"))) { | |
continue | |
} | |
$path = $path.Substring(12).Replace("/", "\") | |
$lastSlashIndex = $path.LastIndexOf("\") | |
$folderName = $path.Substring($lastSlashIndex + 1) | |
if ($lastSlashIndex -eq 0) { | |
"Creating root folder: $folderName" | |
New-PublicFolder $folderName | |
} else { | |
$parent = $path.Substring(0, $lastSlashIndex) | |
"Creating new child folder in parent: $parent" | |
"Child folder: $folderName" | |
New-PublicFolder -Path $parent -Name $folderName | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment