locked
How to delete a user's Deleted Items through Powershell? RRS feed

  • Question

  • I would like to delete a user's Deleted Items through powershell, but include ALL sub folders as well.  

    I have this command that works to delete the items in the Deleted Items folder, but it does note delete subfolders:

    Get-Mailbox user1 | Export-Mailbox -DeleteContent -IncludeFolders "\deleted items"

    Can anyone offer assistance?

    Thanks!

    Friday, November 4, 2011 2:24 PM

Answers

    • but the sub folders themselves still exist. 

    This command will not delete the sub folders.


    Jasjit Singh Dhindsa | ITIL v3 | IASA Foundation Certified | MCITP:EMA Exchange 2010/2007 | MCTS:OCS 2007 | Exchange 2010/2007 | MCSA:Messaging/Security | MCSE:Messaging/Security
    • Marked as answer by itzafugasi Monday, November 7, 2011 3:51 PM
    Friday, November 4, 2011 3:02 PM
  • Hi
      
    The IncludeFolders parameter specifies the list of folders to include during the export. It doesn’t include subfolder. My suggestion is to set up retention policy on the mailbox. It affect subfolder.

    • Marked as answer by itzafugasi Monday, November 7, 2011 3:51 PM
    Monday, November 7, 2011 6:55 AM

All replies

  • Try this:

    Get-Mailbox -Identity user1 | Export-mailbox -DeleteContent -IncludeFolders "\deleted items", "\NameOfSubFolder", "\AnotherNameOfSubfolder", etc...

    Friday, November 4, 2011 2:48 PM
  • Thanks.  The issue we're facing is we don't necessarily know the names of the subfolders, we just want them all removed.  I noticed that the items do get deleted from the sub folders when I run the command i listed, but the sub folders themselves still exist.  
    Friday, November 4, 2011 2:56 PM
    • but the sub folders themselves still exist. 

    This command will not delete the sub folders.


    Jasjit Singh Dhindsa | ITIL v3 | IASA Foundation Certified | MCITP:EMA Exchange 2010/2007 | MCTS:OCS 2007 | Exchange 2010/2007 | MCSA:Messaging/Security | MCSE:Messaging/Security
    • Marked as answer by itzafugasi Monday, November 7, 2011 3:51 PM
    Friday, November 4, 2011 3:02 PM
  • Set yourself to have full permission of the mailbox and map it through Outlook(Advanced>Open these additional mailboxes). You'll see the user then delete the files...
    Friday, November 4, 2011 3:18 PM
  • Hi
      
    The IncludeFolders parameter specifies the list of folders to include during the export. It doesn’t include subfolder. My suggestion is to set up retention policy on the mailbox. It affect subfolder.

    • Marked as answer by itzafugasi Monday, November 7, 2011 3:51 PM
    Monday, November 7, 2011 6:55 AM
  • hello,

    i'm unable to get your command to work. Here is the message that I get.

    the term 'Export-mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program...

    Get-Mailbox user1 | Export-Mailbox -DeleteContent -IncludeFolders "\deleted items"

    Can you please tell me what I may be missing?

    Thanks in advance,

    Alex

    Thursday, March 27, 2014 6:01 PM