Change Regional Setting Using PnP PowerShell

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.
 
Change Regional setting using PnP PowerShell
 
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.
  1. #Set the required Variables  
  2. $SiteURL = "https://contoso.sharepoint.com"  
  3. $Timezone = "(UTC-08:00) Pacific Time (US and Canada)"  
  4. #Connect to SharePoint Online with PnP PowerShell  
  5. Connect - PnPOnline - Url$siteURL - Credentials(Get - Credential)  
  6. #Get the Web  
  7. $web = Get - PnPWeb - IncludesRegionalSettings.TimeZones  
  8. #Get the time zone  
  9. $Tzone = $Web.RegionalSettings.TimeZones | Where {  
  10.     $_.Description - eq$Timezone  
  11. }  
  12. If($Timezone - ne$Null) {  
  13.     $Web.RegionalSettings.LocaleId = 1036 # French  
  14.     $Web.RegionalSettings.WorkDayStartHour = 9  
  15.     $Web.RegionalSettings.WorkDayEndHour = 6  
  16.     $Web.RegionalSettings.FirstDayOfWeek = 0 # Sunday  
  17.     $Web.RegionalSettings.Time24 = $False  
  18.     $Web.RegionalSettings.CalendarType = 1 #Gregorian  
  19.     $Web.RegionalSettings.AlternateCalendarType = 0 #None  
  20.     $Web.RegionalSettings.WorkDays = 124  
  21.     $Web.Update()  
  22.     Invoke - PnPQuery  
  23.     Write - host "Timezone is Successfully Updated " - ForegroundColorGreen  
  24. }  
  25. else {  
  26.     Write - host "Can't Find Timezone $TimezoneName " - ForegroundColorRed  
  27. }  
After running the above code, we can check if the regional setting of the provided site is changed successfully.
 
Before running the script,
 
Change Regional setting using PnP PowerShell
 
After running the script,
 
Change Regional setting using PnP PowerShell
 
I hope the given piece of code is helpful to change the regional setting without giving too much of effort by changing it manually.