The process of building custom solutions for SharePoint Server.
Hi @developer sp1 ,
Here is a complete code demo to set time zone for your reference:
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$TimezoneName = "(UTC+04:00) Abu Dhabi, Muscat"
#Connect to SharePoint Online with PnP PowerShell
Connect-PnPOnline $SiteURL -UseWebLogin
#Get the Web
$web = Get-PnPWeb -Includes RegionalSettings.TimeZones
#Get the time zone
$Timezone = $Web.RegionalSettings.TimeZones | Where {$_.Description -eq $TimezoneName}
If($Timezone -ne $Null)
{
#Update time zone of the site
$Web.RegionalSettings.TimeZone = $Timezone
$Web.Update()
Invoke-PnPQuery
Write-host "Timezone Updated Successfully!" -ForegroundColor Green
}
else
{
Write-host "Timezone $TimezoneName not found!" -ForegroundColor Yellow
}
You missed Invoke-PnPQuery in your code snippet which applied the changes.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.