Export all mailboxes to pst of inactive users

Welcome Forums General PowerShell Q&A Export all mailboxes to pst of inactive users

This topic contains 1 reply, has 2 voices, and was last updated by  Forums Archives 3 years, 1 month ago.

  • Author
  • #6542

    Points: 0
    Rank: Member

    by Zadnak at 2013-04-09 14:38:52

    Hi all,

    We are about to migrate to a new domain and I need to export all mailboxes to pst of inactive users. We plan to delete the users off Exchange after they have been archived. I was able to generate a report of the inactive users using this command:

    Get-Mailbox | Get-MailboxStatistics | Where {($_.LastLogonTime -lt (get-date).adddays(-60))} |export-csv z:\users_older_than_60.csv

    I was wondering what command I need to run next to mass export to pst those users. I'm working with Exchange 2010 for this.

    Thanks in advance!

    by DonJ at 2013-04-09 23:33:56

    So, you're after the Export-Mailbox command, I suppose. Use Get-Mailbox to get the maiboxes you want, pipe them to Export-Mailbox, and use its -PSTFolderPath to specify a destination folder.

    by Zadnak at 2013-04-10 10:29:45

    So my command should be

    Get-Mailbox | Get-MailboxStatistics | Where {($_.LastLogonTime -lt (get-date).adddays(-60))} | New-MailboxExportRequest -Filepath z:\pstfiles

    Is that enough for Powershell to understand what I want? I'm AWFUL with sintax, so that's why I'm asking.

    by Kottees at 2013-04-11 02:29:56

    Hi, Try this.
    foreach ($i in (Get-Mailbox | Get-MailboxStatistics | Where {($_.LastLogonTime -lt (get-date).adddays(-60))})) { New-MailboxExportRequest -Mailbox $i -FilePath "\\Exports\$($i.Alias).pst" }

    by Zadnak at 2013-04-13 15:45:09

    I get this when running ^that command:

    Cannot process argument transformation on parameter 'Mailbox'. Cannot convert the "Microsoft.Exchange.Data.Mapi.MailboxStatistics" value of type "Microsoft.Exchange.Data.Mapi.MailboxStatistics" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
    + CategoryInfo : InvalidData: (:) [New-MailboxExportRequest], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MailboxExportRequest

    Thanks for the help!

    by ArtB0514 at 2013-04-15 08:45:53

    You just need to move the Where-Object clause before the Get-MailboxStatistics call so that the Mailbox gets returned and not the statistics object at the end of the pipeline.

    foreach ($i in (Get-Mailbox | Where-Object {($_ | Get-MailboxStatistics).LastLogonTime -lt (Get-Date).AddDays(-60)})) {do-export-here}

    by Zadnak at 2013-04-15 14:43:18

    Running ^that command, I get

    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

    by ArtB0514 at 2013-04-15 16:28:45

    Ah, so. I keep forgetting about that. Try it this way and see if it works.
    foreach ($I in (Get-Mailbox | Where-Object {(Get-MailboxStatistics $_.Name).LastLogonTime -lt (Get-Date).AddDays(-60)})) {do-export-task-here}

    I don't have access to Exchange right now, so can't really check this. I'll think about it more tonight and see how it works when I get to the office tomorrow.

    by ArtB0514 at 2013-04-16 06:28:28

    Hmmm. Still gets the running pipeline error. Oh, well, this way isn't very efficient, but it does work:

    $Day60 = (Get-Date).AddDays(-60)
    $Mailboxes = Get-Mailbox -ResultSize Unlimited
    $Mailboxes = $Mailboxes | Where-Object {(Get-MailboxStatistics $_.Name).LastLogonTime -lt $Day60}
    foreach ($I in $Mailboxes) {do-export-task-here}

    by Adom503 at 2013-04-26 02:57:40

    Whenever I used powershell scripts for the inactive users mailboxes or disconnected mailboxes, i came in trouble. Now thing is that what I did to overcome here, just deployed a small edb pst application that did this job smoothly. You may check:



    by Zadnak at 2013-05-01 07:18:25

    Hmmm. Still gets the running pipeline error. Oh, well, this way isn't very efficient, but it does work:

    $Day60 = (Get-Date).AddDays(-60)
    $Mailboxes = Get-Mailbox -ResultSize Unlimited
    $Mailboxes = $Mailboxes | Where-Object {(Get-MailboxStatistics $_.Name).LastLogonTime -lt $Day60}
    foreach ($I in $Mailboxes) {do-export-task-here}

    This worked perfectly! Thank you very much for your help.

The topic ‘Export all mailboxes to pst of inactive users’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort