Introduction
Changing Regional settings of a SharePoint Online site manually is straightforward but if someone needs to change the regional settings for all the sites then it will be a time-consuming procedure.
So here I have tried to make the task a bit easier. I have made a PowerShell script to change the regional setting in the site. Here, I have used PnP online to perform this action. We have to follow the below steps to write the script.
Step 1
Run ISE in administrative mode.
Step 2
Declare two variables named “SiteURL” and “Timezone” and store the values of the site Url and the time zone which you want to set for your site.
Step 3
Connect PnP online and get the credentials by using the below command.
Connect-PnPOnline-Url$siteURL-Credentials (Get-Credential)
Step 4
Get the web including the region setting and then get the time zone by using the PnP commands as shown in the code.
Step 5
Copy and run the below codes to set/change the regional setting.
- #Set the required Variables
- $SiteURL = "https://contoso.sharepoint.com"
- $Timezone = "(UTC-08:00) Pacific Time (US and Canada)"
- #Connect to SharePoint Online with PnP PowerShell
- Connect - PnPOnline - Url$siteURL - Credentials(Get - Credential)
- #Get the Web
- $web = Get - PnPWeb - IncludesRegionalSettings.TimeZones
- #Get the time zone
- $Tzone = $Web.RegionalSettings.TimeZones | Where {
- $_.Description - eq$Timezone
- }
- If($Timezone - ne$Null) {
- $Web.RegionalSettings.LocaleId = 1036 # French
- $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
- $Web.RegionalSettings.WorkDays = 124
- $Web.Update()
- Invoke - PnPQuery
- Write - host "Timezone is Successfully Updated " - ForegroundColorGreen
- }
- else {
- Write - host "Can't Find Timezone $TimezoneName " - ForegroundColorRed
- }
After running the above code, we can check if the regional setting of the provided site is changed successfully.
Before running the script,
After running the script,
I hope the given piece of code is helpful to change the regional setting without giving too much of effort by changing it manually.