Set SharePoint regional settings
Script will set custom regional settings in your sharepoint site
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
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.
Tool documentation & references
- Want to learn more about PnP PowerShell and the cmdlets
Check out the PnP PowerShell site to get started and for the reference to the cmdlets.