开发者

Script to move mail from x folders to 1 folder in an exchange mailbox

We have an exchange 2007 server with a lot of mailboxes. We are used to u开发者_运维技巧se a lot of folders and drop the messages in this subfolders. I want a list with mailboxes and the total size of the mailbox, the itemcount and the count of folders so I wrote the following script.

Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | Foreach-Object{

    $mbx = $_
    $count = 0

    $mbx | Get-MailboxFolderStatistics | Foreach-Object{ $count++ }

    $mbx | Select-Object @{label='DisplayName';expression={$mbx.DisplayName}}, @{label='Total Size (MB)';expression={$mbx.TotalItemSize.Value.ToMB()}},@{label='Items';expression={$mbx.ItemCount}}, @{label='Folders';expression={$count}}
} > c:\mailboxes.txt

This works great but we want to restrict the number of folders in exchange to 10 subfolders (for example). I wonder if there is an solution to move messages from all folders to 1 subfolder and remove the empty folders.

Does any of you have an solution for powershell (c# is also possible)


I see a couple of possibilites.

  1. Use export-mailbox to export all the email from the folders you want to delete to one you want to keep.

  2. Use Exchange Web Services (via the EWS Managed API) to move the items from the folders you want to delete to the one you want to keep.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜