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
Does anyone have a suggestion? Many Thanks!