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 with 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:

  • Navigate to your SharePoint Online site >> Click on Settings >> Site Settings
  • Under the “Site settings” page, click on “Regional Settings” link under “Site Administration” (/_layouts/15/regionalsetng.aspx)
  • 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
  • When you visit the regional settings at the root site, you have an 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)

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published.