Last active
August 9, 2016 08:18
-
-
Save bill-long/9d1cf8abb1faf8d39408 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$path = '\\server\path\' | |
$mailboxes = get-mailbox somemailboxfilter | |
$mailboxes | % { | |
$folders = Get-MailboxFolderStatistics $_.Alias -archive | |
$folders = $folders | ? {$_.Name -ne "Top of Information Store"} | |
$excludeFolders = $folders | % { $_.FolderPath.Substring(1) } | |
New-MailboxExportRequest -Mailbox $_.Alias -ExcludeFolders $excludeFolders -ExcludeDumpster -IsArchive -FilePath ($path + $_.Alias + '.pst') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We (Wharton) ended up having difficulty with users who had forward slashes in their folder paths, as it appears as a different (unrecognized?) character type in the FolderPath and other properties, and thus doesn't get interpreted in total as a valid folder path in the exclude array.
My solution (based off of the link below) was to do a replace of the (proper) forward slash with a backslash, split the directory structure based on the backslash, replace the badly encoded character with a proper forward slash and escape it (with a backslash) per directory, and rejoin on the forward slash for a valid path.
https://social.technet.microsoft.com/Forums/en-US/a7706dc3-67a4-4a8d-99b0-3de879e9554b/question-marks-and-forwardslashes-in-outlook-folder-names-and-how-to-use-with?forum=winserverpowershell