Mailbox export and completed status by Powershell

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of AniyaNetworks AniyaNetworks 7 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35040
    Profile photo of AniyaNetworks
    AniyaNetworks
    Participant

    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
    Profile photo of Yuan Li
    Yuan Li
    Participant

    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
    Profile photo of AniyaNetworks
    AniyaNetworks
    Participant

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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.