SOLVED

Apply a Office 365 Security & Compliance retention policy to specific users

%3CLINGO-SUB%20id%3D%22lingo-sub-161699%22%20slang%3D%22en-US%22%3EApply%20a%20Office%20365%20Security%20%26amp%3B%20Compliance%20retention%20policy%20to%20specific%20users%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-161699%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20cannot%20use%20organization%20wide%20retention%20policies%20to%20cover%20all%20Exchange%20Online%20mailboxes%20or%20OneDrive%20sites%20because%20of%20different%20needs%20on%20different%20countries.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIs%20there%20a%20way%26nbsp%3Bwe%20can%20apply%20a%20retention%20policy%20to%20specific%20group%20of%20users%20and%20then%20also%20maintain%20the%20provisioning%20of%20new%20users%20and%20de-provisioning%20of%20leavers%3F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIt%20seems%20that%20you%20can%20use%20shell%20to%20add%20mail-enabled%20group%20to%20a%20retention%20policy%20using%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3ESet-RetentionCompliancePolicy%20-Identity%20%22Policy_name%22%20-AddExchangeLocation%20%22group_email%22%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3Eto%20get%20the%20group%20members%20extracted%20and%20added%20to%20the%20policy.%20This%20would%20be%20simple%20enough%20to%20schedule%20to%20be%20run%20and%20maintain%20the%20group%20memberships%20in%20on-prem%20AD%2C%20but%20it%20seems%20that%20the%20re-adding%20the%20same%20group%20does%20not%20update%20the%20mailboxes%20affected%20by%20the%20policy.%20Then%20again%2C%20you%20cannot%20just%26nbsp%3B%3CEM%3E-RemoveExchangeLocation%20%22group_email%22%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esince%20the%20removal%20command%20only%20takes%20individual%20users%20and%20not%20groups.%20So%20scheduled%20task%20could%20first%20find%20the%20current%20individuals%20affected%20by%20the%20retention%20policy%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3E%3CSTRONG%3E(how%3F)%3C%2FSTRONG%3E%3C%2FEM%3E%2C%20remove%20them%20and%20then%20re-add%20the%20group.%20to%20get%20the%20updates%20in%20group%20memberships.%20Seems%20a%20bit%20complicated%20and%20possibly%20even%20risky%20if%20you%20remove%20users%20from%20the%20policy%20and%20re-adding%20them%20will%20not%20work%20for%20some%20reason%20leaving%20users%20without%20a%20hold...%20has%20anyone%20any%20better%20ways%20to%20automate%20this%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20that's%20only%20the%20Exchange%20part%20-%20the%20OneDrive%20needs%20url%20of%20the%20site%20and%20groups%20can%20not%20provide%20that%20without%20some%20heavy-scripting.%20Has%20anyone%20any%20great%20ideas%20how%20to%20handle%20the%20provisioning%20and%20de-provisioning%20on%20those%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-162045%22%20slang%3D%22en-US%22%3ERe%3A%20Apply%20a%20Office%20365%20Security%20%26amp%3B%20Compliance%20retention%20policy%20to%20specific%20users%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-162045%22%20slang%3D%22en-US%22%3E%3CP%3EWhy%20do%20you%20need%20to%20remove%20users%20though%3F%20Generally%20speaking%2C%20the%20requirements%20to%20keep%20data%20also%20apply%20to%20leavers%2C%20so%20there%20should%20be%20no%20need%20to%20update%20the%20policy%20every%20time%20a%20person%20leaves%20the%20company.%20But%20to%20answer%20the%20question%2C%20the%20way%20to%20find%20out%20which%20policies%20apply%20to%20which%20objects%20is%20to%20look%20at%20the%20corresponding%20mailbox%20attributes.%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%5B09%3A57%3A21%5D%23%20(Get-Mailbox%20vasil).InPlaceHolds%0Ambxda45e521e0314dd19ec276112c2af7b9%3A2%0A%0A%5B09%3A59%3A01%5D%23%20Get-RetentionCompliancePolicy%20da45e521e0314dd19ec276112c2af7b9%0A%0AName%20%20%20%20%20%20%20%20%20%20Workload%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Enabled%20Mode%0A----%20%20%20%20%20%20%20%20%20%20--------%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-------%20----%0APersonalStuff%20Exchange%2C%20SharePoint%2C%20OneDriveForBusiness%2C%20Skype%2C%20ModernGroup%20True%20%20%20%20Enforce%3C%2FPRE%3E%0A%3CP%3Ewhere%20I've%20stripped%20the%20%22mbx%22%20prefix.%20For%20company-wide%20policies%2C%20you%20should%20look%20into%20the%20output%20of%20the%20Get-OrganizationConfig%20cmdlets%20instead.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20agree%2C%20it%20can%20be%20handled%20in%20a%20better%20manner.%20And%20ODFB%20handling%20is%20crap%2C%20we've%20been%20asking%20for%20years%20now%20to%20have%20it%20changed%20based%20on%20UPN%20or%20something%20instead%20of%20having%20to%20always%20specify%20the%20URL.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

We cannot use organization wide retention policies to cover all Exchange Online mailboxes or OneDrive sites because of different needs on different countries.

Is there a way we can apply a retention policy to specific group of users and then also maintain the provisioning of new users and de-provisioning of leavers?

It seems that you can use shell to add mail-enabled group to a retention policy using:

Set-RetentionCompliancePolicy -Identity "Policy_name" -AddExchangeLocation "group_email"

to get the group members extracted and added to the policy. This would be simple enough to schedule to be run and maintain the group memberships in on-prem AD, but it seems that the re-adding the same group does not update the mailboxes affected by the policy. Then again, you cannot just -RemoveExchangeLocation "group_email" since the removal command only takes individual users and not groups. So scheduled task could first find the current individuals affected by the retention policy (how?), remove them and then re-add the group. to get the updates in group memberships. Seems a bit complicated and possibly even risky if you remove users from the policy and re-adding them will not work for some reason leaving users without a hold... has anyone any better ways to automate this?

 

And that's only the Exchange part - the OneDrive needs url of the site and groups can not provide that without some heavy-scripting. Has anyone any great ideas how to handle the provisioning and de-provisioning on those?

1 Reply
best response confirmed by Tero Voutilainen (New Contributor)
Solution

Why do you need to remove users though? Generally speaking, the requirements to keep data also apply to leavers, so there should be no need to update the policy every time a person leaves the company. But to answer the question, the way to find out which policies apply to which objects is to look at the corresponding mailbox attributes. For example:

 

[09:57:21]# (Get-Mailbox vasil).InPlaceHolds
mbxda45e521e0314dd19ec276112c2af7b9:2

[09:59:01]# Get-RetentionCompliancePolicy da45e521e0314dd19ec276112c2af7b9

Name          Workload                                                      Enabled Mode
----          --------                                                      ------- ----
PersonalStuff Exchange, SharePoint, OneDriveForBusiness, Skype, ModernGroup True    Enforce

where I've stripped the "mbx" prefix. For company-wide policies, you should look into the output of the Get-OrganizationConfig cmdlets instead.

 

 

I agree, it can be handled in a better manner. And ODFB handling is crap, we've been asking for years now to have it changed based on UPN or something instead of having to always specify the URL.