Detect if a user is or isn't under a particular In-Place Hold

Let's say that you want to put an 3 year time based in-place hold on all (or a large group) of your users. You set up a process, script or whatever to modify the hold whenever you need to add a user. 

Great.

So, how can you make sure that you didn't miss someone?

You can use a combination of the "InPlaceHoldIdentity" of the Mailbox Search object for your hold and the "InPlaceHolds" Multivalue string attribute of your mailboxes.

First, find the ID of the hold you want to look for:

Here I am looking for a hold named “demo”

 

PS C:\Users\stevenha> Get-MailboxSearch demo | fl name,inplaceholdidentity 

Name : Demo

InPlaceHoldIdentity : d14862810adc4f6a8621bd868b551660

 

That “InPlaceHoldIdentity” value is stored in every user that the hold applies to. Like this:

 

PS C:\Users\stevenha> get-mailbox sarad | fl name,inpla*

  

Name : SaraD

InPlaceHolds : {d37259985eae4cba8f795d53f8bafc84, 1e6cecf94b6641a088a484d6128bf77a, e850fa01c5f746f2b5d8d46dd5d2eee4,

               b223bed883f34071b279f58835472740...}

 

So, we can look for any users that have that hold in place like this:

 

PS C:\Users\stevenha> get-mailbox -resultsize unlimited | where {$_.inplaceholds -contains "d14862810adc4f6a8621bd868b551660"}

 

Or, we can look for any users that DO NOT have the hold like this:

 

PS C:\Users\stevenha> get-mailbox -resultsize unlimited | where {-not $_.inplaceholds -contains "d14862810adc4f6a8621bd868b551660"}