locked
Delete all emails in Inbox RRS feed

  • Question

  • Hi,

    I have a test mailbox in Exchange Online. In the test mailbox I have more than 100000 emails in Inbox - how to delete all emails in the Inbox only using Powershell ?


    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.

    Tuesday, January 22, 2019 9:33 AM

Answers

  • Hi,

    hhhmmmm, https://office365.uservoice.com/forums/264636-general/suggestions/16904902-powershell-command-to-purge-specific-mailbox-folde


    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.

    Yes, Retention Policy is a better choice so far. You could create a folder tag for Inbox, select the action to permanently delete the items and set the retention period to let them expire at once.   

    Another method to work around this is to open the mailbox in Outlook, click on one email on Inbox, then use Ctrl+A to select all and right click to delete it. After that, do the same operations on the Deleted Items folder and Recover Deleted Items folder.

    For reference: Retention tags and retention policies.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Edited by Manu Meng Wednesday, January 23, 2019 6:51 AM
    • Proposed as answer by Manu Meng Thursday, January 24, 2019 12:29 PM
    • Marked as answer by dktoa Friday, February 1, 2019 1:54 PM
    Wednesday, January 23, 2019 2:48 AM

All replies

  • You can use this provided if you have permission to perform this action-

    $to   = ((Get-date).AddDays(-1)).ToShortDateString()
    $from = ((Get-date).addmonths(-12)).ToShortDateString()
    Search-Mailbox -Identity usermailbox -SearchQuery {"Received:$from..$to"} -DeleteContent -Force

    Imp: Ensure you are mentioning the correct usermailbox else you will be in data loss if wrong ID is specified.


    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Check out my latest blog posts on http://exchangequery.com Thanks Sathish (MVP)

    Tuesday, January 22, 2019 12:05 PM
  • Hi,

    And this will delete from Inbox only ?


    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.

    Tuesday, January 22, 2019 12:32 PM
  • Hi,

    hhhmmmm, https://office365.uservoice.com/forums/264636-general/suggestions/16904902-powershell-command-to-purge-specific-mailbox-folde


    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.

    • Proposed as answer by Manu Meng Wednesday, January 23, 2019 2:46 AM
    Tuesday, January 22, 2019 1:29 PM
  • Hi,

    hhhmmmm, https://office365.uservoice.com/forums/264636-general/suggestions/16904902-powershell-command-to-purge-specific-mailbox-folde


    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.

    Yes, Retention Policy is a better choice so far. You could create a folder tag for Inbox, select the action to permanently delete the items and set the retention period to let them expire at once.   

    Another method to work around this is to open the mailbox in Outlook, click on one email on Inbox, then use Ctrl+A to select all and right click to delete it. After that, do the same operations on the Deleted Items folder and Recover Deleted Items folder.

    For reference: Retention tags and retention policies.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Edited by Manu Meng Wednesday, January 23, 2019 6:51 AM
    • Proposed as answer by Manu Meng Thursday, January 24, 2019 12:29 PM
    • Marked as answer by dktoa Friday, February 1, 2019 1:54 PM
    Wednesday, January 23, 2019 2:48 AM
  • Just checking in to see if above information was helpful. Please let us know if you would like further assistance.

    Regards, 

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to shareexplore and talk to experts about Microsoft Teams.

    • Proposed as answer by Manu Meng Tuesday, January 29, 2019 1:21 PM
    Friday, January 25, 2019 10:44 AM