Solved

How do use New-MailboxExportRequest to see if a mailbox is being exported, if so, wait for it to finish.

Posted on 2016-08-25
3
28 Views
Last Modified: 2016-08-31
I am writing a powershell script that uses Get-MailboxExportRequest to export out mailboxes.  Before I call Get-MailboxExportRequest, I want to confirm there are no other request running for the same account.  If there are, I would like to wait.

I have written the code below that waits if there is an existing MailboxExportRequest.  However, my issue is if there is not, this sits in an endless loop.  

while(!(Get-MailboxExportRequest -Mailbox $mailBoxName.Alias -Status Completed))
{
	Sleep -s 300
}

Open in new window


Does anyone have a suggestion?  Many Thanks!
0
Comment
Question by:rye004
  • 2
3 Comments
 

Accepted Solution

by:
rye004 earned 0 total points
ID: 41771130
I think I figured this out.  I need to use an IF statement before using the while loop.  Below is the code:

if((Get-MailboxExportRequest -Mailbox $mailBoxName)){
	while(!(Get-MailboxExportRequest -Mailbox $mailBoxName.Alias -Status Completed))
	{
		Sleep -s 300
	}
}

Open in new window

0
 
LVL 11

Expert Comment

by:Tej Pratap Shukla ~Dexter
ID: 41771278
Hi,
You can go through below link to learn about execution of New-MailboxExportRequest Command. You can some live running command images with proper configuration as well as requirement.

http://exchange-server-guide.blogspot.com/2016/03/how-to-export-edb-mailbox-to-pst.html
0
 

Author Closing Comment

by:rye004
ID: 41777758
I was able to figure this out after posting.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
A brief introduction to what I consider to be the best editor for PowerShell.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question