SOLVED

Applying OneDrive Retention Policy to a Group

%3CLINGO-SUB%20id%3D%22lingo-sub-1005807%22%20slang%3D%22en-US%22%3EApplying%20OneDrive%20Retention%20Policy%20to%20a%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005807%22%20slang%3D%22en-US%22%3E%3CP%3EI%20know%20you%20can%20create%20a%20One%20Drive%20retention%20policy%20against%20individual%20personal%20URLs%2C%20but%20I%20was%20wondering%20if%20there%20is%20anyway%20to%20automate%20this%20via%20an%20AD%20group%20or%20a%20specific%20AD%20attribute.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%20we%20have%20a%20department%20that%20needs%20a%20specific%20retention%20policy%20set%20and%20I%20would%20like%20to%20see%20if%20we%20can%20automate%20adding%20them%20into%20the%20retention%20policy%20rather%20than%20having%20this%20as%20a%20manual%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20sync%20our%20on-prem%20AD%20with%20AADC.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1005807%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ERetention%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006161%22%20slang%3D%22en-US%22%3ERe%3A%20Applying%20OneDrive%20Retention%20Policy%20to%20a%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006161%22%20slang%3D%22en-US%22%3E%3CP%3ESadly%2C%20even%20after%20years%20of%20us%20asking%20for%20simplifying%20the%20experience%20when%20it%20comes%20to%20stamping%20retention%20on%20ODFB%20sites%2C%20the%20controls%20in%20the%20portal%20still%20only%20accept%20URLs.%20But%2C%20you%20can%20do%20it%20easily%20via%20PowerShell.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006271%22%20slang%3D%22en-US%22%3ERe%3A%20Applying%20OneDrive%20Retention%20Policy%20to%20a%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006271%22%20slang%3D%22en-US%22%3EOk%20so%20could%20we%20query%20the%20users%20URL%20by%20a%20certain%20AD%20attribute%2C%20for%20example%20department%20attribute%3F%20Do%20you%20have%20any%20examples%20of%20how%20to%20do%20this%20via%20powershell%20please%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007593%22%20slang%3D%22en-US%22%3ERe%3A%20Applying%20OneDrive%20Retention%20Policy%20to%20a%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007593%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20are%20multiple%20samples%20online%20that%20you%20can%20use%20to%20enumerate%20ODFB%20drives%2C%20or%20filter%20them%20by%20some%20criteria.%20The%20simplest%20ones%20are%20listed%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fonedrive%2Flist-onedrive-urls%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fonedrive%2Flist-onedrive-urls%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20need%20a%20more%20robust%20method%2C%20you%20can%20use%20CSOM%20or%20the%20Graph%20API%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007611%22%20slang%3D%22en-US%22%3ERe%3A%20Applying%20OneDrive%20Retention%20Policy%20to%20a%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007611%22%20slang%3D%22en-US%22%3EThanks%20I%20found%20some%20examples%20last%20night%20that%20use%20CSOM.%3C%2FLINGO-BODY%3E
Frequent Contributor

I know you can create a One Drive retention policy against individual personal URLs, but I was wondering if there is anyway to automate this via an AD group or a specific AD attribute.

 

Basically we have a department that needs a specific retention policy set and I would like to see if we can automate adding them into the retention policy rather than having this as a manual process.

 

We sync our on-prem AD with AADC.

4 Replies
best response confirmed by blue-man (Frequent Contributor)
Solution

Sadly, even after years of us asking for simplifying the experience when it comes to stamping retention on ODFB sites, the controls in the portal still only accept URLs. But, you can do it easily via PowerShell.

Ok so could we query the users URL by a certain AD attribute, for example department attribute? Do you have any examples of how to do this via powershell please?

There are multiple samples online that you can use to enumerate ODFB drives, or filter them by some criteria. The simplest ones are listed here: https://docs.microsoft.com/en-us/onedrive/list-onedrive-urls

If you need a more robust method, you can use CSOM or the Graph API

Thanks I found some examples last night that use CSOM.