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
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
To show how to generate a certificate request 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 Servers >> Certificates…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

635 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