Editing Locale and Timezone Settings for Office 365 Groups using PowerShell

Problem definition:

  • Files created under Office 365 Groups or OneDrive for Business exhibit PST timezone formatting. You can replicate this by creating an Excel document and typing 1/12, which is then auto-formatted by Excel to say 12th Jan. In the UK, we mean 1st Dec.
  • This timezone issue occurs even if Groups are created with en-GB as the locale.

The following code snippet allows you to programmatically edit the Locale and Timezone for an Office 365 Group using PowerShell. It requires you to be an owner on the group. It may also be adapted to edit a user’s personal site (see bottom of article).



# Define required variables:
$Office365GroupURL = 'https://tenancyname.sharepoint.com/sites/YourO365Group'
$TimeZoneID = 2
$LocaleID = 2057

# Specify Office 365 UPN with group (site) ownership permissions:
$User = "user@yourdomain.com"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString

# Add references to SharePoint client assemblies:
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"

# Create SharePointOnlineCredentials class object:
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)

# Perform the work:
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Office365GroupURL)
$Context.Credentials = $Creds
$Context.Web.RegionalSettings.LocaleId = $LocaleID
$Context.Web.RegionalSettings.TimeZone = $Context.Web.RegionalSettings.TimeZones.GetById($TimeZoneID)


  • This works against personal sites, using the personal site URL. An example might be: https://tenancyname-my.sharepoint.com/personal/username_domain_com
  • Still investigating how to perform this operation as an administrator against sites (possibly using Set-SPOSite to add an owner, then removing afterwards).

One thought to “Editing Locale and Timezone Settings for Office 365 Groups using PowerShell”

Leave a Reply to Priya Cancel reply

Your email address will not be published.