Author Posts

February 9, 2016 at 7:59 am

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"

February 9, 2016 at 5:14 pm

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


February 10, 2016 at 10:33 am

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