No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

Delete user mailbox without deleting user

This question is answered This question is answered

We have ran a trial migration to office 365 this put some emails in all users mailboxes including their folder hierarchy. The folders are fine but I want to delete all the emails from the account before performing the full migration.

 

I have tried to delete the users outlook licenses and then give it back but the users emails were still present.

 

I don't want to recreate all user accounts because we have spent a LONG time manually recreating our distribution lists and other user account information.

Verified Answer
  • Hey Guys with microsoft support I have put the finishes touches on this issue. Using retention policy was a great idea thanks Allan. Here are my steps how to solve this problem

    Create policy:

    New-RetentionPolicy <name> -RetentionPolicyTagLinks <list of retention tags>

    Create Policy Tag:

    New-RetentionPolicyTag <name> -Type <type of tag> -AgeLimitForRetention <retention age limit, in days> -RetentionAction <action to take when retention age is met>

    Apply to all mailboxes:

    Get-Mailbox | Set-mailbox -RetentionPolicy "<policy name>"

    Force the retention policy:

    $User = Get-mailbox -Filter {(RecipientTypeDetails -eq 'UserMailbox')}

    $User | ForEach {Start-ManagedFolderAssistant $_.Identity}

    and POOF the mail is gone.

    Thanks again for everyone's assistance. I will be back here sometime I am sure to try and figure out what is up with search-mailbox but that is a fight for another day.

    1 out of 1 people found this post helpful.

All Replies
  • Hi Adam,

     

    Based on your description, I understand that you want to only migrate users' mailbox to Office 365 but no any emails of users, you may want to purge users mailbox before the migration. If I misunderstand the issue, please feel free to let me know.

     

    If you only want to migrate the user's mailbox to Office 365 but without any emails, we can achieve this by importing users with a CSV file, for more detailed information, please refer the link below:

    Import New Exchange Online Users with a CSV File

     

    If the above do not help, could you please provide more detailed information about your situation such as:

    1.Are you migrate from on-premise exchange server to Office 365?

    2.If so, what kind of migration you are performing? Cutover Migration or Staged Migration?

     

    Thanks,
    Jolin Qiao

    1 out of 1 people found this post helpful.

  • Hey Jolin,

    Ya you missed the point a bit. Let me clarify and share what office365 support suggested.

    So we have already imported the users from CSV and using MigrationWiz we have done a test migration to make sure that our connectors where setup correctly they were and a handful of emails were moved over from our old server to the new users. My manager does not want these old emails to be present when we migrate. So I need to clear out the mailbox without deleting the users.

    I don't want to delete users because of the data and setting that have been given to the users will be erased.

    Support told me to remove the exchange licenses and then give it back. This is supposed to remove the mailbox with keeping user settings.

    This hasn't worked as planned though. I have only competed two tests.

    First test after deleting the license and waiting a while to put it back the data was still in the mailbox.

    Test two:

    After the same first steps the account was unable to sign into outlook in portal. After some powershell commands we determined that the mailbox creation date was the same as the original. It was supposed to be rest and have a date of today.

    I have an official support ticket in and will post here with what comes from it.

    If you have any suggestions please let me know.

  • Adam,

    What is the reason to delete the old emails before the full migration with MigrationWiz? If you are using Migration for the full migration after the trial, they will not duplicate any emails if you are using the same connector.

  • Louis,

    I am aware of that. But my director does not like the idea of having the mail have to be managed twice by the our employees. Once on the current account and again after the migration.

    It isn't a deal breaker style problem but the fact that Microsoft supports suggestions aren't working the way they expected is frustrating. And mostly I just want to figure out how to solve the problem.

    Thanks,

  • If you log on to the Exchange Control Panel, go to mailboxes, select the user and click the X button it should do what you want.

    See this URL

    help.outlook.com/.../bb847822.aspx

    "In Microsoft Office 365, deleting a mailbox has no effect on the user ID. The Microsoft Online Services ID that's associated with the mailbox is retained. See Delete a mailbox in the Exchange Control Panel in Office 365."

    I'd do it on a test user first to see if it has the desired effect!

  • Actually, this will delete the entire mailbox - not the content.  Not sure what effect this has on distribution groups.

    Alternatively, you can try creating a new retention policy that deletes all emails older than 1 day and applying it to all mailboxes.

  • Hey Alan,

    Ya I actually did that on my own account because I read that it was safe. This lead to an embarrassing case were it actually deleted my account completely and I need another Admin to recreate my account.

    I am at a lose right now so I will give it a shot again on a different account this time though.

    Thanks,

  • Haha - don't you love it when documentation lies to you!

    What about trying a discovery search with the -deletecontent switch

    Search-Mailbox -id "UserName" -DeleteContent

    If that works, you may be able to do something like

    get-mailbox | Search-Mailbox -id "UserName" -DeleteContent

    I've not tested this last command for obvious reasons....

  • Hey Alan,

    That sounded like a great Idea! I tried but to no avale. I created a new retention policy with 1 day and applied it to two different accounts I have been testing on.

    Powershell:

          New-RetentionPolicyTag "DELETE TEST EMAILS TAG" -Type All -AgeLimitForRetention 1 -RetentionAction PermanentlyDelete

          New-RetentionPolicy "DELETE TEST EMAILS POLICY" -RetentionPolicyTagLinks "DELETE TEST EMAILS TAG"

    The new policy shows up fine and looks like a beauty. I have delayed this post to give it ample time to take effect. But no luck the emails are still there on both accounts.

    Is there a way to force retention policies actions.

    Secondly I have been looking at the "get-mailbox | Search-Mailbox -id "UserName" -DeleteContent" but my powershell errors because it doens't recognize the Search-Mailbox command.

    I am wicked new to powershell but have lots of linux experience so I do not fear the command line.

    I was curious if there was a way to install new commandlets or if it is just the server's service pack that doesn't support command.

    Thanks,

  • Hi Adam,

     

    About the error you running the PowerShell command, it should be "-Identity" other than "-id", for more detailed information about this cmdlet, please refer Search For and Delete Messages from Users' Mailboxes.

     

    In addition, it seems that you have already submit a Service Request, would you please provide your SR number with private message for me? Therefore, I will help you to monitor this case? To request the SR number, I have sent a private message with a subject of <Delete user mailbox without deleting user> to you.

     

    To access the private message:

    -Go to the Your details section on the right side of the community site.

    -Click Private messages.

    -Click the subject title of the response to read the message

     

    Thanks,
    Jolin Qiao

  • For the retention policy, you may need to force the policy to apply immediately using the following cmdlet

    Start-ManagedFolderAssistant -Identity <name of the mailbox>

    Or to do it on all mailboxes

    get-mailbox | Start-ManagedFolderAssistant

    Regading the search-mailbox command, Jolin is absolutely right, I buggered up the powershell command myself.

    If you do a get-mailbox | search-mailbox you shouldn't need to use the -identity command at all.

    Get-mailbox will list all mailboxes in your tenant, it will then pass these mailboxes one by one as an object to the search-mailbox command (rather than as text like in the linux world)

    So it should be something like

    get-mailbox | Search-Mailbox -DeleteContent

    But test it first on one mailbox using

    get-mailbox | Search-Mailbox -identity "UserName" -DeleteContent

    The article Jolin posts has a load of information, including the -LogOnly parameter which will log what actions the cmdlet would have taken rather than actually delete the messages.

    Sorry again for the confusion, tab completion let me down!

  • Hey Alan/Jolin,

    Search-Mailbox isn't working still. When trying to run I receive this error.

    "The term 'Search-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program."

    I have tried with piping get-mailbox into it.

    Using tab completion I see a "Search-MailboxAuditLog" I have full admin control so should have access to all commands on the server.

    I have just ran the "Start-ManagedFolderAssistant" for applicable mailbox.

    Know any reason why I wouldn't be able to run Search-Mailbox?

    Thanks for all the help.

  • Sorry for multiple post. But the Start-MangedFolderAssistant worked!

  • Good to hear.  You may need to be in the Discovery Management Role to use search-mailbox.

  • I have put myself on the Discovery Management Role and search-mailbox doesn't seem to be working still.

    Also I used the Start-MangedFolderAssistant manually for my test email addresses but when I try to pipe get-mailbox into it I get errors thrown.

    "The input object cannot be bound to any parameters for the command either because the command does not take pipline input or the input and its properties do not match any of the parameters that take pipeline input."

    Seems like the syntax is incorrect. Not sure if this needs something like "get-mailbox | Start-ManagedFolderAssistant -identitiy $x" or something to tell the pipe where to put info. Again new to powershell.

    Thanks,