Change OneDrive For Business locale

Hello, here I am back with another script to share with you. Recently a client asked me how to change locale of OneDrive in bulk for his Office 365 users. The thing is that his Office 365 tenant has been created with french as default language, whereas there are many englishspeaking people in the company.

Of course you can change this default language through OneDrive online site settings > Regional settings

    This script allows you to change regional settings in Office 365 OneDrive For Business.
    This script allows you to change regional settings in Office 365 OneDrive For Business.
    Full path to upns TXT or CSV file (without header), one UserPrincipalName (upn) per line.
    Specify Admintrator UserPrincipalName
    Specify SharePoint Admin site url : "https://<yourtenant>", replace <tenant> with your tenant name
    Specify OneDrive For Business url : "https://<yourtenant>, replace <tenant> with your tenant name
    Specify the Locale ID. The locale ID for US english (en-us) is 1033
    Set-OD4BLocale -UpnPath "C:\upns.txt" -creds "" -SiteURL "" -ODUrl "" -LocaleID 1033
    Version :          1.0
    Auteur :           Jean-Marie AGBO
    Date de création : 04/12/2018
    Version 1.0 :  Développement initial        

Function Set-OD4BLocale{




        [string]$LocaleID = "1033"    

  #Connect msol service
  Connect-SPOService -Url $SiteURL -Credential $creds

  #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"
  #Import upn file
  $Upns = Get-Content -Path $UpnPath

  foreach ($upn in $Upns){      
    #Building user ODrive Full Url
    Write-Host "Building ODrive Full Url for $upn" -ForegroundColor Yellow
    $ODriveFullUrl = $ODUrl +  $Upn.Replace("@","_").replace('.','_') 
    #Adding Admin access to user OneDrive
    Write-Host "Adding Admin access to $upn OneDrive" -ForegroundColor Yellow
    Set-SPOUser -Site $ODriveFullUrl -LoginName $creds.UserName -IsSiteCollectionAdmin $true | Out-Null 
    #Bind to OD4B Site and change locale
    Write-Host "Changing Locale for $upn" -ForegroundColor Yellow 
    $spocreds = [Microsoft.SharePoint.Client.SharePointOnlineCredentials]::new($Creds.UserName,$creds.Password)
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($ODriveFullUrl)
    $Context.Credentials = $spocreds
    $Context.Web.RegionalSettings.LocaleId = $Locale                  
    #Removing Admin access from User OneDrive
    Write-Host "Removing Admin access from $upn OneDrive" -ForegroundColor Green
    Set-SPOUser -Site $ODriveFullUrl -LoginName $creds.UserName -IsSiteCollectionAdmin $false | Out-Null 

How to run the script ?

Set-OD4BLocale -UpnPath "C:\upns.txt" -creds "" -SiteURL "" -ODUrl "" -LocaleID 1033

The upns.txt file must contain the UserPrincipalName of users you want to change the locale.

You can get help on the script. Run it and use the below PowerShell command line :

Get-Help Set-OD4BLocale -Full

After changing the default language:

Change OD4B locale2

Now, you can check your change by creating an excel file in OneDrive Online and note that the formula are in english.


Et voilà 🙂 !

16 thoughts on “Change OneDrive For Business locale

Add yours

  1. i have tried to run this script it ran but did not change the language of the onedrive site for the users .


    1. Hi Daniel,
      The purpose of this script is not to change the onedrive site language but the regional settings. Regional settings allow you to specify how the site displays numbers, dates, and times.

      If you want to change your OneDrive display language, you must do it in the settings of your Office 365 account :


  2. When i run this script i get the following error “Exception calling “.ctor” with “2” argument(s): “The ‘username’ argument cannot be null.” Do you have any idea what l’m doing wrong?



  3. when I try to run the script, simply nothing happens. not sure why. are there any prerequisites for the script to run on a windows 10 system?


  4. Trying to work out what the locale ID would be – eg for English Australia or English UK – I assume the 1033 is for French?


  5. Very good script, especially that you can specify the UPNs. I am having trouble running the script though. I have saved the script as Set-OD4BLocale.ps1, but when running it nothing happens. I have installed CSOM and Sharepoint Online Module.

    .\Set-OD4BLocale.ps1 -UpnPath “C:\Scripts\upns.txt” -creds “” -SiteURL “” -ODUrl “” -LocaleID 2057

    Liked by 1 person

  6. Having the same issue as Wian Swart – when running the .\Set-OD4BLocale.ps1 – nothing happens – not sure how to use/call the function – can you show me specifics on how how to run this


  7. Thanks! Working great, but I also need to change the “Specify the sort order” to General at the same time. Is there a way to add this into the script?


  8. Hey. The script is giving access to the admin I specify and removes access at the end, but the locale doesn’t change and i don’t get any errors. I tried different decimal locale Ids . Thank you!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: