OneDrive for Business comes as part of Office 365, and while it sounds like its a separate product, it’s really just SharePoint Online as the backend. As an administrator, there may be some settings you would like to control when rolling out ODfB to your end users. Some of these features can be applied from the GUI and as a global setting, but others need to be administered on a site by site basis. I think you know what’s coming next… PowerShell to the rescue.
As I said ODfB is a SharePoint site, specifically a MySite. The site has a Document library called documents. The site admin is the owner of the ODfB, so they have access to all the site settings. This means that any changes you make at the site level can be reversed by the site admin, and Microsoft does not support removing site admin privileges from the owner. So the good news is that you can change settings programatically on the back-end. The bad news is that users can alter your desired settings if they want to, even though most users wouldn’t even know where to go to do it.
With that disclaimer out of the way, there are some settings that end users can’t change. Data Loss Prevention settings can be applied to a group of ODfB sites or all ODfB sites. That can be set from the Compliance Center in Office 365 and applies to current and newly created sites. Preservation policies can be applied from the portal as well, but only to existing sites. There is no way to set a default preservation policy for all ODfB sites. Both DLP and preservation policies cannot be changed by the end user, so once it’s set up you can rest easy.
Versioning and Information Rights Management (IRM) settings are applied at the site library level, and as such can be changed by the end user. There is also no way of applying a default group of settings to all existing sites from the portal, unless you count going to each site individually and manually editing the sites.
I wrote the script below with the help of examples from TechNet, especially the portions that used the Client Side Object Model (CSOM), which I had never even heard of before.
Director, Cloud Solutions and Microsoft MVP: Cloud (Azure/Azure Stack) & DC Mgmt