Removing mailbox (Remove-Mailbox) right after mail export to PST request (New-MailboxExportRequest)

Hi all,
I have a PowerShell script for archiving employee mailboxes after they leave the company. The script uses WinRM to connect to Exchange CAS where it:
exports user mailbox to PST files (New-MailboxExportRequest -Mailbox $user -FilePath $USER_ARCH\mail\MAIL_$user.pst)
export user archive mailbox to PST file (New-MailboxExportRequest -Mailbox $user -isarchive -FilePath $USER_ARCH\mail\Archive_$user.ps)
delete user mailbox (Remove-Mailbox $user
These 3 steps are executed one after another. Since New-MailboxExportRequest is asynchronous (only creates requests and exists), the
Remove-Mailbox is triggered right after the request is submitted. Since PST file is not created or is truncated, I believe
Remove-Mailbox actually removes mailbox even though there is active request for that mailbox. Logically the mailbox with bound active requests should not be removed and there should be warning.
I know there are many possible workarounds. Just want to know if this is by design or am I missing an option to above commands?
Best regards,
     Blaz

The same happens in Exchange 2010 making this seem like it is by design.  I can find no reference as to how to avoid this other than by changing your script.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Similar Messages

  • New-mailboxExportRequest exports the entire folder in spite of filter conditions

    Hi there,
    got an issue with exporting mailboxes,
    script below exports entire inbox folder rather than just emails in the mentioned time frame
    $export_date= [datetime]"10/29/2014 12:00:00 AM"
    New-MailboxExportRequest -FilePath \\server\export\matthew.pst -IncludeFolders "#inbox#" Mailbox matthew_2014 -ContentFilter {( received -ge $export_date) }
    already checked the value of $export_date it returns the right datetime value

    Hi Mcmilad,
    Try this and let me know if it works.
    I removed the var with direct input, just to check if its working now for you.
    The script shot above has missing hypen before -Mailbox parameter, And I have changed -gt instead of -ge
    New-MailboxExportRequest -FilePath \\server\export\matthew.pst -IncludeFolders "#inbox#" -Mailbox matthew_2014 -ContentFilter {(Received -gt "10/29/2014") }
    New-MailboxExportRequest -FilePath \\server\export\matthew.pst -IncludeFolders "#inbox#" -Mailbox matthew_2014 -ContentFilter {(Received -lt '11/29/2014') -and (Received -gt '10/29/2014')}
    Filterable properties for the -ContentFilter parameter:
    http://technet.microsoft.com/en-us/library/ff601762(v=exchg.150).aspx
    Regards,
    Satyajit
    Please“Vote As Helpful”
    if you find my contribution useful or “MarkAs Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Exchange 2010 SP1 - Export to PST, Remove Mailbox

    I'm looking for a PowerShell script that will allow me to use Exchange 2010 SP1 to export a mailbox to PST and then when finished, delete the user and mailbox. I typically do this process manually about 6 months after an employee leaves the company (allowing
    for live access to the mailbox and message forwarding to their supervisor).
    Ideally, the script would take input for a mailbox ID, and then export the file to a file of the mailbox name (Prompt: jdoe -> New-MailboxExportRequest -Mailbox jdoe -FilePath \\server\path\jdoe.pst). After the export is complete, it would schedule the
    mailbox for complete removal and remove the completed mailbox export request. The prompt and export process should be simple enough, but I suspect the difficulty will come with monitoring for the completed request before acting on the removal.
    Thanks for any help provided! :)

    Thanks for the guidance!
    I think I was able to come up with something that will do the trick nicely:
    $Name = Read-Host "Please enter a mailbox to archive"
    New-MailboxExportRequest -Mailbox $Name -FilePath \\Exchange\C$\ExchangeExports\$Name.pst
    while ((Get-MailboxExportRequest -Mailbox $Name | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
    sleep 60
    Get-MailboxExportRequest -Mailbox $Name | Remove-MailboxExportRequest -Confirm:$false
    Remove-Mailbox -Identity $Name -Confirm:$false
    Hopefully it may help others.

  • HT2500 How do I remove the deleted mailbox from the sidebar on Mail?

    How do I remove the deleted mailbox from the sidebar on Mail?  Anyone knows how? Hit delete and dragging to the Trash but none seems to work.

    Hi, try highlighting it the Right click or Control+click & see if Delete Mailbox is an option.

  • How can I remove a mailbox address from the "From" drop down box in a new e-mail my old e-mail address continue to populate as the sender address

    How can I remove a mailbox address from the "From" drop down box in a new e-mail my old e-mail address continue to populate as the sender address

    Hello,
    Try Mail>Preferences>Accounts icon>Account Information tab>Click on the Outgoing SMTP server drop down, choose edit Server list, highlight the old one & click Remove.
    (Such convolution is worthy of Windows® in my estimation)

  • How do I remove an entire email account from mail if it does not allow me to click "remove mailbox"?

    How do I remove an entire email account from mail if it does not allow me to click "remove mailbox"?

    Welcome to the Apple Community.
    Unfortunately you can't delete accounts, you also can't change or remove iCloud addresses.

  • I inadvertently removed the junk mailbox from Mail.app in SL, how can I recreate / restore it ?

    Hi,
    Well, the title says it all : I inadvertently removed the junk mailbox from Mail.app in SL,
    it still is spresent in my ~/library/mail folder, how can I recreate / restore it in mail.app ?
    Since I have a fair number of email accounts, intelligent mailboxes, rules and archive folder, I really don't want to rebuild everything. And, no, I can't use time machine to restore it.
    All help will be greatly appreciated.

    Hi AdamKB, sorry for late follow-up.
    What I lost is the "container" that groups all junk mailboxes in one place in Mail, like is done for all the inboxes.
    The problem is that I lost visibility on all junk mailboxes. It is only a visibility problem because the junk mailboxes are still present locally for my POP accounts and remotely for may IMAP accounts, I justdon't see them anymore in Mail's interface.

  • Exchange 2010: Remove high available mailbox database error

    Hello everyone,
    I have a two node DAG exchange 2010 and recently split one mailbox database into two databases. 
    Now when removing the original database I get the following error:
    Please provide specific details.
    The following was done thus far:
    Deleted all softdeleted items
    this is not the default mailbox database
    Suspended the second mail server and removed it from mailbox, leaving now just one mail server attached to the mailbox database.
    Help

    Try to check mailbox import request is there or no by this command. Get-MailboxImportRequest. If you can see any requests listed. Remove it by this command Get-MailboxImportRequest | Remove-MailboxImportRequest.
    Thanks, MAS
    Please mark as helpful if you find my comment helpful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

  • HT5527 I have had my storage reduced once already.  In the process they removed my "Save" mailbox and all its contents.  I do notcare about contents so much as starting a new Save box.  How?  (OS X 10.7.5)

    My iCloud storage is being reduced.  I have already had it reduced once.  In the process they removed my "Save" mailbox and all its contents.  (One would think that that would be the last thing they removed.  But they took that and the "Trash" mailbox, yet left several thousand old and read messages which were in my "Inbox".)  I do not expect to get the "Save" contents back, but I would like to restore the "Save" mailbox, so that I can start from scratch saving msgs in it again.  But I cannot figure out how to do that.  When I go to "Mailbox" on the top line (between View and Message) and select New Mailbox I get a dialog box in which I can name a new mailbox.  When I type Save, for the name of the new Mailbox I get a response; "The mailbox 'Save" already exists."  But I cannot find it.
    Thanks,  Bill Burner

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In Library Manager it's the FIle -> Rebuild command)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. 
    Regards
    TD 

  • HT2486 How do I export a mailbox to address book from Mail

    How do I export a mailbox to address book from mail?

    Unless you are willing to continually do an export of one contacts database and import of the other, switching back and forth, you'll either need to use some third-party contacts application or maintain two separate user accounts in Mac OS X. The built-in Address Book/Contacts application does not allow multiple address books.
    Regards.

  • How to Remove a bad mailbox server and add new mailbox server to DAG and copy mailboxes over

    DAG
    2- cas - VM
    2- mbx- physical blade  (mbx1, mbx2)
    5- mailbox databases
    OS: Win 2008 SP2
    Exchange 2010SP3
    Storage: Tegile Disk jbod  Luns
    We have bad disks on mbx1.  our plan is to get a new blade to replace the bad one named mbx3. we need to do this asap since we are running on 1 server without failover capability
    How can I safely:
    1. Add a new mailbox server to the DAG
    2. Copy\Move the databases from the old (passive) server to the new server
    3. Remove the bad mailbox server from DAG

    You'll want to make sure that the new server is on all the same networks that the server you are removing is on, specifically networks that are DAG networks. Also, you'll want to avoid using Windows Network Load Balancing on the new mailbox server
    since it will be part of the DAG. Also, just as you did with the current DAG members, ensure that the disk drive letters match the existing disks that hold databases & logs. Other than that, it's as simple as you have stated.
    1.) Once you have the new mbx server built & configured with the mailbox role, you can use:
    Get-DatabaseAvailabilityGroup "Name of DAG" | Add-DatabaseAvailabilityGroupServer "Name of New MBX Server"
    2.) Add the databases to the new DAG member:
    Add-MailboxDatabaseCopy "name of database" -MailboxServer "name of new DAG member" -ActivationPreference "[you decide based on the server replacing mbx1]"
    3.) Once your databases are Mounted and/or Healthy on the new DAG member, you'll want to remove the databases from the "bad" server (make sure they are all passive on the server first):
    Get-MailboxDatabaseCopy "SERVER\Database" | Remove-MailboxDatabaseCopy
    4.) Once all of the databases are removed from the "bad" DAG member, remove him from the DAG:
    Get-DatabaseAvailabilityGroup "Name of DAG" | Remove-DatabaseAvailabilityGroupServer "Name of old MBX Server"
    Before you pull the blade, uninstall Exchange Server gracefully, as this will save you AD & Exchange headaches later on.
    Petri has a pretty good GUI walk-through for some of the above steps here:
    How to Configure Database Availability Group for Exchange Server 2010
    Woody Colling, MCITP Exchange 2010
    --The incentive for the experts to answer posts is to get their replies marked as helpful, or as the answer to our questions, help them help us, mark posts accordingly--

  • Office365 - Move Mailbox and Export to PST

    Hi Everyone
    So we have moved all our Mailboxes to Office365 and I am in the process of setting up our service desk checklists etc.
    One issue that i have came across is that it is not possible to directly export mailboxes from Exchange Online to PST.
    We are in a Hybrid Environment so it is still possible to migrate mailboxes off to a local Mailbox Server and export from there.
    In order to streamline this as much as possible i have written the following (UnTested!) script.  I will be using it from the Azure Powershell Module already connected to our online tenant and so that section of code has been removed.
    If anyone had any thoughts in regards to this - or can point out any glaringly obvious mistakes that would be great!
    #Script to Move User MailBox from Exchange Online to OnPrem and Export To PST
    #Created By: Joe McGrath
    #Created On: 17/12/2013
    #Mailbox move
    $OnpremCred=get-credential
    $User= Read-Host 'Enter the username of the user'
    new-moverequest -identity $User -OutBound -RemoteTargetDatabase 'YOURDB' -RemoteHostName ‘mail.YOURDOMAIN.com’ -RemoteCredential $OnpremCred -TargetDeliveryDomain ‘YOURDOMAIN.com’
    #The Next Section Checks the Status of the move every 60 seconds
    $MoveStatus=""
    $MoveStatus = Get-MoveRequest -Identity $User
    do
        Start-Sleep -Seconds 60
        $MoveStatus = Get-MoveRequest -Identity $User
    While ($MoveStatus.Status -ne 'Completed')
    Write-Host "Mailbox Move Completed."
    #When the Move has completed we now clear the move request
    Remove-MoveRequest -identity $User
    Write-Host "Move Request Cleared from System"
    #This next section will carry out the Export to PST
    #We need to call the Exchange 2010 Powershell cmdlets and connect to the On Premises Exchange Infrastructure to Export to PST
    Write-host "Connecting to On Premises Exchange"
    $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://Server.YOURDOMAIN.local/PowerShell" -Credential $OnpremCred
    Import-PSSession $ExchangeSession
    $filePath='\\Server\Share\'
    #This First Command Exports the Users Primary Mailbox to PST
    Write-Host "Beginning Primary Mailbox Export to PST for "+$User
    New-MailboxExportRequest -Mailbox $User -FilePath $filePath+$User+".pst"
    $MailboxExportStatus=""
    $MailboxExportStatus = Get-MailboxExportRequestStatistics -Identity $User
    Do
        Start-Sleep -Seconds 60
        $MailboxExportStatus = Get-MailboxExportRequestStatistics -Identity $User
    While ($MailboxExportStatus.Status -ne 'Completed')
    Remove-MailboxExportRequest -Identity $User
    Write-Host "The Primary Mailbox for "+$User+" Has been exported."
    Write-Host "Exporting Archive Mailbox for "+$User
    #This Command Exports the Users Archive to PST
    Write-Host "Exporting Archive Mailbox for "+$User
    New-MailboxExportRequest -Mailbox $User -IsArchive -FilePath $filePath+$User+"_Archive.pst"
    $ArchiveExportStatus=""
    $ArchiveExportStatus = Get-MailboxExportRequestStatistics -Identity $User
    Do
        Start-Sleep -Seconds 60
        $ArchiveExportStatus = Get-MailboxExportRequestStatistics -Identity $User
    While ($ArchiveExportStatus.Status -ne 'Completed')
    Remove-MailboxExportRequest -Identity $User
    Write-Host "The Archive Mailbox for "+$User+" Has been exported."
    Remove-PSSession $ExchangeSession
    Write-Host "User Mailbox has been Removed from Online and Archived to file"
    Like I said this is not tested yet - I need an account to test with - after I manually migrate the data first :) - so use at your own risk etc

    Hi,
    You can not export the Office365 mailbox Data in to PST, you must have to bring the mailbox to on premises and then export, once done again move back the mailbox to office365,
    another way is from in-place hold, search the mailbox and take users PST, or user third party tool such as messageops which is quite good.

  • Help with 550GB mailbox export to PST

    Unfortunately, that isn't a typo. In preparation for enabling the retention policy, our majority owner of multiple companies was running rules to sort mail to/from specific recipients into custom folders, and the rules created hundreds of thousands of duplicates.
    That issue has a PSS support case already.
    So, we need to find the best way to remove all the duplicates from his mailbox. We are very worried about using a 3rd-party tool such as ODIR on his production mailbox and having it create more problems. We have at least two full backups of his
    mailbox in the current state but due to the size if it does need to be restored that'll cause another huge delay, but there would be challenges restoring the database because we don't have enough free space to restore the database which contains his mailbox
    (the database is normally 250GB, now it's almost 800GB). There are 13 subfolders >15GB, 10 > 20GB, 9 > 30GB, and 9 between 30-75GB.
    I tried creating mailbox export requests for about a half dozen of those folders. The thought was we'd run ODIR against those exported PSTs so at least if it failed it wouldn't affect his production mailbox. So far the export jobs have been running
    about 20 hours and while the item count is increasing, it's not going very quickly. They have a virtual CAS and a physical HT/MBX, and it was spec'ed for normal operations which are nothing like this. So the 8GB RAM on the MBX server is pegged, and the 2GB
    which the CAS server has is all we can give it due to limits on the virtual host.
    I've attempted to suspend a few of the jobs  to see if that would quicken the pace for the remaing jobs, but I am greeted with 'The call to MRS' timed out. I've increased the timeout to 20min in the web.config file but not restarted any services because
    1) the documents which referenced the change didn't tell me to do so and 2) worried about how the service restart will affect the work already completed by the jobs.
    Any ideas on how to proceed would be wonderful.
    Thanks,
    Jim

    Hi Jim,
    Here are links relate on Exporting Mailbox, for your reference:
    Create a Mailbox Export Request
    http://technet.microsoft.com/en-us/library/ff459227(v=exchg.141).aspx
    Please notice the AcceptLargeDataLoss , BadItemLimit Parameters in New-MailboxExportRequest cmdlet.
    How to Export Mailboxes with Exchange Server 2010 SP1
    http://exchangeserverpro.com/export-mailboxes-exchange-server-2010-sp1/
    Disclaimer:
    Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure
    that you completely understand the risk before retrieving any suggestions from the above link.
    I also suggest export part of mailboxes for testing.
    Thanks
    Mavis
    Mavis Huang
    TechNet Community Support

  • How do I remove the superscript number from the Mail icon on the Dock?

    I have unsuccessfully  searched all folders and topics on the left side of the Mail page to find one supposed incoming email, as the Mail icon indicates with a numeral One on the Mail Icon in the dock to no avail.  How can I either find this unread email via a shortcut, or remove the superscript "1" from the Mail icon on the Dock? Thanks!

    Hmm, this seems kind of too obvious, but when I look at Mail, in the MAILBOXES sidebar on the left, every mailbox and folder has an oval to the right of its name listing how many unread messages it has.  (Sadly, I have a lot of ovals with big numbers in them!)
    Doesn't one of your ovals have a "1" in it?
    Hope that helps...
    Ivan

  • My iCloud mailboxes do not show in mail

    My icloud mailboxes do not appear in mail. I have reinstalled icloud several times.

    Quit Mail. Force quit if necessary.
    Back up all data. That means you know you can restore the Mail database, no matter what happens.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Mail/V2/MailData
    Copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder
    from the menu bar. Paste into the box that opens (command-V), then press return.
    A folder window will open. Inside it there should be files with names as follows:
    Envelope Index
    ExternalUpdates.storedata
    Move those files to the Desktop, leaving the window open. Other files in the folder may have longer names that begin as above. Move those files, if any, to the Trash.
    Log out and log back in. Relaunch Mail. It should prompt you to re-import your messages. You may get a warning that the index is damaged and that Mail has to quit. Click OK. Typically, the process takes a few minutes, but it may take hours if you have gigantic mailboxes. In that case, you may be able to speed things up by temporarily adding your home folder to the Privacy list in the Spotlight preference pane. Remove it when Mail has finished importing.
    Test. If Mail now works as expected, you can delete the files you moved to the Desktop. Otherwise, post your results.

Maybe you are looking for