SharePoint Online: Change Regional Settings using PowerShell

Requirement: Change regional settings in SharePoint Online using PowerShell

How to Change Regional Settings in SharePoint Online?
Changing 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()

Here is my other post on changing time zone using PowerShell: SharePoint Online: Change Time Zone using PowerShell, Refer this Microsoft documentation for all regional setting values: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ms443292(v=office.15)

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.