SharePoint Online: Change Regional Settings using PowerShell

Requirement: Change regional settings in SharePoint Online using PowerShell.

How to Change Regional Settings in SharePoint Online?

By default, the regional settings are selected from Site creation Settings in the SharePoint Admin Center at the time of site creation. However, you may need to change these settings depending on your location or the preferred language to ensure everyone uses the same date-time and currency formats. Whatever the reason, it’s easy to change your regional settings in SharePoint Online using PowerShell or the browser. This article will show you how to change regional settings in SharePoint Online.

Changing the regional settings of a SharePoint Online site is straightforward:

  1. Navigate to your SharePoint Online site >> Click on Settings >> Site Settings.
  2. Under the “Site settings” page, click on the “Regional Settings” link under “Site Administration” (/_layouts/15/regionalsetng.aspx).
  3. In the “Regional Settings” page, you can set all regional settings for the site, such as Time Zone, Locale, Sort order, calendar, work week, time format.sharepoint online regional settings powershell
  4. When you visit the regional settings at the root site, you have the option to apply the settings to all sub-sites in the site collection.

SharePoint Online: Set Regional Settings using PowerShell

Here is the SharePoint Online PowerShell to change regional settings:

#Load SharePoint CSOM 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"
 
#Config parameters for SharePoint Online Site URL and Timezone description
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
 
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
   
#Set up the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Ctx.Credentials = $credentials
$Web = $Ctx.Web
 
#Update Regional Settings in sharepoint online using powershell
$Web.RegionalSettings.LocaleId = 1033 # English
$Web.RegionalSettings.WorkDayStartHour = 9
$Web.RegionalSettings.WorkDayEndHour = 6

$Web.RegionalSettings.FirstDayOfWeek = 0 # Sunday
$Web.RegionalSettings.Time24 = $False

$Web.RegionalSettings.CalendarType = 1 #Gregorian
$Web.RegionalSettings.AlternateCalendarType = 0 #None

#64 = Sunday; 32 = Monday; 16 = Tuesday; 8 = Wednesday; 4 = Thursday; 2 = Friday; 1 = Saturday;  All Days = 127; None = 0 
$Web.RegionalSettings.WorkDays = 124

$Web.Update()
$Ctx.ExecuteQuery()

PnP PowerShell to Change Regional Settings in SharePoint Online

If you need to change your regional settings in SharePoint Online, you can do it quickly and easily with PnP PowerShell:

#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/Purchase"
$LocaleId = 2057 # UK
$TimeZoneId = 2 # London

#Connect to Site
Connect-PnPOnline $SiteURL -Interactive

#Get the Web
$Web = Get-PnPWeb -Includes RegionalSettings,RegionalSettings.TimeZones

#Get the Timezone
$TimeZone = $web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $TimeZoneId}

#Update Regional Settings
$Web.RegionalSettings.TimeZone = $TimeZone
$Web.RegionalSettings.LocaleId = $LocaleId
$Web.Update()
Invoke-PnPQuery

SharePoint Online: Set Regional Settings for All Sites in the Tenant

How about changing the regional settings for all sites? Here is the PnP PowerShell way to change the regional settings for all sites in SharePoint Online using PowerShell:

#Parameter
$TenantAdminURL = "https://Crescent-admin.sharepoint.com"
$LocaleId = 2057 # UK
$TimeZoneId = 2 # London

#Function to Set Regional Settings on SharePoint Online Web
Function Set-RegionalSettings
{ 
    [cmdletbinding()]
    Param(
        [parameter(Mandatory = $true, ValueFromPipeline = $True)] $Web
    )
 
    Try {
        Write-host -f Yellow "Setting Regional Settings for:"$Web.Url
        #Get the Timezone
        $TimeZone = $Web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $TimeZoneId} 
        #Update Regional Settings
        $Web.RegionalSettings.TimeZone = $TimeZone
        $Web.RegionalSettings.LocaleId = $LocaleId
        $Web.Update()
        Invoke-PnPQuery
        Write-host -f Green "`tRegional Settings Updated for "$Web.Url
    }
    Catch {
        write-host "`tError Setting Regional Settings: $($_.Exception.Message)" -foregroundcolor Red
    }
}

#Connect to Admin Center
$Cred = Get-Credential
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
  
#Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
$SitesCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
  
#Loop through each site collection
ForEach($Site in $SitesCollections)
{
    #Connect to site collection
    Connect-PnPOnline -Url $Site.Url -Credentials $Cred
 
    #Call the Function for all webs
    Get-PnPSubWeb -Recurse -IncludeRootWeb -Includes RegionalSettings, RegionalSettings.TimeZones | ForEach-Object { Set-RegionalSettings $_ }
}

Here is my other post on changing time zone using PowerShell: SharePoint Online: Change Time Zone using PowerShell

Refer to this Microsoft documentation for all regional setting values: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ms443292(v=office.15)

Summary

In conclusion, changing the regional settings for a SharePoint Online site can be done easily using site settings or PowerShell. By utilizing the SharePoint Online CSOM or PnP PowerShell module, users can easily update the regional settings for their SharePoint Online site, including the time zone, language, and regional format. This allows users to customize their SharePoint Online experience and ensure that their site is configured to meet their specific needs and requirements. Additionally, PowerShell scripting offers a faster and more efficient way of managing the regional settings of multiple sites at the same time.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

4 thoughts on “SharePoint Online: Change Regional Settings using PowerShell

  • Anyone have an idea if this can be run against sites created in the last week or so? This script helped me get all current sites to the region required, however newly created sites will still have the incorrect region.

    I have attempted a script but it appears SPO has no ‘date.created’ attribute in powershell, only in GUI.

    Reply
    • You need to change the default setting in sharepoint admin center.

      Reply
  • For SharePoint Online: Set Regional Settings for All Sites in the Tenant, I had some issues with this working against my environment with MFA/2FA. Made some changes and this appears to do the trick

    #Parameter
    $TenantAdminURL = "https://CONTOSO-admin.sharepoint.com"
    $LocaleId = 2057 # English - United Kingdom en-GB (From: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a)
    $TimeZoneId = 2 # London (From: https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spregionalsettings.timezones?view=sharepoint-server)
     
    #Function to Set Regional Settings on SharePoint Online Web
    Function Set-RegionalSettings
    {
        [cmdletbinding()]
        Param(
            [parameter(Mandatory = $true, ValueFromPipeline = $True)] $Web
        )
      
        Try {
            Write-host -f Yellow "Setting Regional Settings for:"$Web.Url
            #Get the Timezone
            $TimeZone = $Web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $TimeZoneId}
            #Update Regional Settings
            $Web.RegionalSettings.TimeZone = $TimeZone
            $Web.RegionalSettings.LocaleId = $LocaleId
            $Web.Update()
            Invoke-PnPQuery
            Write-host -f Green "`tRegional Settings Updated for "$Web.Url
        }
        Catch {
            write-host "`tError Setting Regional Settings: $($_.Exception.Message)" -foregroundcolor Red
        }
    }
     
    #Connect to Admin Center
    #$Cred = Get-Credential - Commented out for MFA use
    Connect-PnPOnline -Url $TenantAdminURL -Interactive
       
    #Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
    $SitesCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
       
    #Loop through each site collection
    ForEach($Site in $SitesCollections)
    {
        #Connect to site collection
        Connect-PnPOnline -Url $Site.Url -Interactive
      
        #Call the Function for all webs
        Get-PnPSubWeb -Recurse -IncludeRootWeb -Includes RegionalSettings, RegionalSettings.TimeZones | ForEach-Object { Set-RegionalSettings $_ }
    }
    
    Reply
    • Keith – are you re-entering your credentials each time you connect to a SharePoint site collection on line 41?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *