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
18 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a Contact 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 Recipients >> Contact ta…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now