Change Regional setting using PnP PowerShell

Introduction

              Changing Regional settings of a SharePoint Online site manually is straight forward 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 -Includes RegionalSettings.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 ” -ForegroundColor Green

}

else

{

    Write-host “Can’t Find Timezone $TimezoneName ” -ForegroundColor Red

}

After running the above code, we can check 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.

Key words:

1.How to change Regional setting using PowerShell.
2.Change the time zone and region settings using PowerShell.
3.Use PowerShell to change the regional setting.

Leave a Reply

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