Set SharePoint regional settings
Summary
Script will set custom regional settings in your sharepoint site
Implementation
- Open Windows PowerShell ISE
- Edit Script and add details of your prefered regional settings
- Press run
###### Declare and Initialize Variables ######
#Destination site collection url
$url="https://<tenant>.sharepoint.com/sites/<yoursitecollection>"
# data will be saved in same directory script was started from
$saveDir = (Resolve-path ".\")
$currentTime= $(get-date).ToString("yyyyMMddHHmmss")
$logFilePath=".\log-"+$currentTime+".log"
## Start the Transcript
Start-Transcript -Path $logFilePath
## Connect to SharePoint Online site
Connect-PnPOnline -Url $Url -Interactive
### Set SharePoint site time zone with Pnp Powershell
$localeId = 2057 # UK
$timeZoneId = 2 # London
$web = Get-PnPWeb -Includes RegionalSettings,RegionalSettings.TimeZones
$timeZone = $web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $timeZoneId}
$web.RegionalSettings.LocaleId = $localeId
$web.RegionalSettings.TimeZone = $timeZone
$web.Update()
Invoke-PnPQuery
### Set Regional Settings using PnP PowerShell
$web = Get-PnPWeb -Includes RegionalSettings
## Define your regional settings in an object
$myRegionalSettings = @{
LocaleId = 1063
WorkDayStartHour = 9
WorkDayEndHour = 6
FirstDayOfWeek = 0
Time24 = $False
CalendarType = 1
AlternateCalendarType = 0
WorkDays = 124
}
$properties = $myRegionalSettings.GetEnumerator()
foreach($property in $myRegionalSettings.GetEnumerator()){
$web.RegionalSettings.$($property.Name)= $property.Value
}
$web.Update()
Invoke-PnPQuery
## Disconnect the context
Disconnect-PnPOnline
## Stop Transcript
Stop-Transcript
Note
Site regional settings can be changed in multiple ways via code. One of the examples of changing reginal setting via site design can be found in this sample Create and add site design to SharePoint site with site columns, content type
Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell
The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?
Source Credit
Sample first appeared on The many ways to set UK Locale in SharePoint
Contributors
Author(s) |
---|
Inspired by Paul Bullock |
Valeras Narbutas |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.