The SharePoint Online CSOM package has just been updated to include some additional functionality, which includes the ability to change the regional settings of a Site - further details on the updated release can be found here.
One of my customers based in the UK wanted to change the Locale of all of their OneDrive for Business Sites to use the English (UK) locale, this is to ensure that dates displayed in the correct format, unfortunately this setting cannot be controlled centrally however with the new functionality available in CSOM I was able to create a script that iterates through all OD4B sites and changes the locale to the desired value.
The script can be found below, simply update the highlighted variables and execute, it will then loop through all OD4B sites and update the locale to the desired value (in my case 2057). You may need to grant the user that executes this script access to the OD4B sites prior to running the script, an example of how to do this can be found here.
To capture new OD4B sites that are created you will need to run this regularly, possibly via a Scheduled Task.
#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
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\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
#Specify tenant admin
$User = "firstname.lastname@example.org"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
#Configure MySite Host URL
$SiteURL = "https://tenant-my.sharepoint.com/"
#Bind to MySite Host Site Collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Context.Credentials = $Creds
#Identify users in the Site Collection
$Users = $Context.Web.SiteUsers
#Create People Manager object to retrieve profile data
$PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Context)
Foreach ($User in $Users)
$UserProfile = $PeopleManager.GetPropertiesFor($User.LoginName)
If ($UserProfile.Email -ne $null)
Write-Host "Updating OD4B site for User:" $User.LoginName -ForegroundColor Green
#Bind to OD4B Site and change locale
$OD4BSiteURL = $UserProfile.PersonalUrl
$Context2 = New-Object Microsoft.SharePoint.Client.ClientContext($OD4BSiteURL)
$Context2.Credentials = $Creds
$Context2.Web.RegionalSettings.LocaleId = "2057"
Brendan Griffin - @brendankarl