Skip to content

Instantly share code, notes, and snippets.

@ykfq
Forked from bill-long/Export-OnlyMailboxRoot.ps1
Created August 9, 2016 08:18
Show Gist options
  • Save ykfq/6289051a92f3abcb787f631e03cabc37 to your computer and use it in GitHub Desktop.
Save ykfq/6289051a92f3abcb787f631e03cabc37 to your computer and use it in GitHub Desktop.
$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