O365 Exchange: Setting Litigation hold, make mailbox inactive and Retention comments

Lets talk about setting Litigation hold and retention comments on O365 mailboxes

Set the Litigation hold

There are some cases where you want to set the mailbox to Inactive status when set the Litigation hold to true. so you want to add the “Inactivemailbox” switch. If you look at this Technet page  regarding this switch, it says that

“This switch is required to use the LitigationHoldEnabled and LitigationHoldDuration parameters on inactive mailboxes”

Seems to be a contradiction on the same page which says

An inactive mailbox is a mailbox that’s placed on Litigation Hold

When I use the command

set-mailbox $upn -litigationholdenabled $true -inactivemailbox

I get an Error/warning

WARNING: If you want to change LitigationHoldEnabled and LitigationHoldDuration

on an inactive mailbox, please add the InactiveMailbox switch.

So the question is how do I make a mailbox inactive? Look at this Msft support article

The article says

Make a mailbox inactive

Making a mailbox inactive involves two steps: placing the mailbox on Litigation Hold or applying an Office 365 retention policy to it, and then deleting the mailbox or corresponding Office 365 user account. After the mailbox is inactive, its contents are retained until the hold or retention policy is removed.

So to make a mailbox inactive you run this command

set-mailbox $upn -litigationholdenabled $true

That begins a backend process in O365 that will move the mailbox to the inactive mailbox collection.

Adding the retention comments

The retention comments can be added when you place a mailbox on litigation hold. example

set-mailbox $upn -litigationholdenabled $true -retentioncomment “legalcase Fr-455”

What about if you want to amend the retention comment later? I would advise you first get the mailbox and then amend the result e.g

get-mailbox $upn -includeinactivemailbox | set-mailbox -litigationholdenabled $false -retentioncomment “Case over 05/05/2015”

It can be more complicated than this. If you want to release LitigationHold on a mailbox that has been inactive for quite a while you have to add the -inactivemailbox switch. Also the retentioncomment switch will not work

set-mailbox -litigationholdenabled $false -inactivemailbox

Once the Litigationhold flag is released, Exchange will immediately expire the mailbox and your get-mailbox will fail unless the mailbox falls under a CaseHold rule in which case Exchange will not expire the mailbox.

Also for error detection instead of using ErrorAction switch use ErrocActionPreference switch before you call the set-mailbox.