Mailbox export and completed status by Powershell

Welcome Forums General PowerShell Q&A Mailbox export and completed status by Powershell

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 years, 10 months ago.

  • Author
    Posts
  • #35040

    Participant
    Points: 0
    Rank: Member

    Hello.
    I am newbie in power-shell. what i am trying to do.
    Export the mailbox and moved to the different location and once the export is done or completed User account will be disabled from AD and mailbox with in an one script automatically.

    what i did, i made 2 two separate script that will do this job. but i cannot combined them. because i dont know how to tell power-shell to wait until the export status changed to complete then run the 2nd script.

    could you guys please advise me .

    Thank you

    ## here is my script

    $DUser = Read-Host "Please enter the User name (e.g: Name.abcw)"

    #Get-MailboxStatistics -Identity $DUser | select *Total*

    [INT]$get=Read-Host "Enter [1] for Continue and [2] for terminate the process."

    if( $get -eq 1){
    $DUserFullName = Read-Host "Please enter the User PST Name (e.g: Name Name2)"
    New-MailboxExportRequest -Mailbox $DUser -FilePath "\\EXCHANGE1\ExportPST\$DUserFullName.PST"
    #Get-MailboxExportRequest -Status Queued
    where }
    elseif ($get -eq 2){
    Write-Host "The process is terminated. Thank you"
    }

  • #35083

    Participant
    Points: 0
    Rank: Member

    I don't have an exchange box to test, but can you do like that?

    New-MailboxExportRequest -Mailbox $DUser -FilePath "\\EXCHANGE1\ExportPST\$DUserFullName.PST" | out-null

    if($? -eq $true) {
    run the 2nd script
    }

    out-null will wait until this command is completed, and $? is the result of the previous command, $true means successful and $false means failure

    Cheers
    Yuan

  • #35124

    Participant
    Points: 0
    Rank: Member

    Hey Yuan,
    Thanks , it is working fine. i tried to export big size of PST . and it is working fine. Thank you

The topic ‘Mailbox export and completed status by Powershell’ is closed to new replies.