New-mailboxExportRequest and New-MailboxImportRequest in sequence

Hi.

I need to export mail to .pst and when status -eq 'complete' then run import .pst to another mailbox. Does anybody know how to do this?

Best Regards Trond Jenssen

  • Take a look at this article: 

    http://www.stevieg.org/2010/07/using-the-exchange-2010-sp1-mailbox-export-features-for-mass-exports-to-pst/

    Write-Output "Waiting for batch to complete"

    # Wait for mailbox export requests to complete
    while ((Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
    {

    sleep 60
    }

  • As an alternative, there is a free tool from Priasoft that can export data using powershell, but is not run from the Exchange server directly.
    Take a look at Super-ExMerge: www.priasoft.com/.../

    You only need a windows host, powershell, and some version of Outlook installed to use it.
    You'll need either FullAccess permissions or the password of the mailbox you want to export.

    Simple in 3 lines of code:
    $endPoints = new-ConnectionInfo -SourceType Mailbox -TargetType Mailbox -SourceSmtp src.user@old.com -SourceServer autodiscover.old.com -SourceCreds 'src.user@old.com:Password' -TargetSmtp new.user@new.com -TargetServer autodiscover.new.com -TargetCreds 'new.user@new.com:Wordpass'
    $task = new-SyncTask $endPoints -OneWaySyncSourceToTarget
    add-SyncTask $task

    you can then check the status periodically using Get-SyncTask -TaskID -States Completed and redo the above 3 lines, but flip the 'source' and 'target' endpoints.

  • As an alternative, there is a free tool from Priasoft that can export data using powershell, but is not run from the Exchange server directly.
    Take a look at Super-ExMerge: www.priasoft.com/.../

    You only need a windows host, powershell, and some version of Outlook installed to use it.
    You'll need either FullAccess permissions or the password of the mailbox you want to export.

    Simple in 3 lines of code:
    $endPoints = new-ConnectionInfo -SourceType Mailbox -TargetType Mailbox -SourceSmtp src.user@old.com -SourceServer autodiscover.old.com -SourceCreds 'src.user@old.com:Password' -TargetSmtp new.user@new.com -TargetServer autodiscover.new.com -TargetCreds 'new.user@new.com:Wordpass'
    $task = new-SyncTask $endPoints -OneWaySyncSourceToTarget
    add-SyncTask $task

    you can then check the status periodically using Get-SyncTask -TaskID -States Completed and redo the above 3 lines, but flip the 'source' and 'target' endpoints.