Short Powershell script that modifies the following settings on every user's OneDrive for Business:

 

 

 

The script is part of Technet Wiki article OneDrive for Business sharing settings with Powershell.

How to use?

 

PowerShell
#Paths to SDK 
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" 

PowerShell
Edit|Remove
#Enter the data 
$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString 
$username="admin@TENANT.onmicrosoft.com" 
$Url="https://TENANT-admin.sharepoint.com" 
$ODBMembersCanShare="On"  # On, Off, Unspecified 
$ODBAccessRequests="Unspecified" #On, Off, Unspecified