Forum Discussion
Time Zone Settings for O365 Groups SharePoint-Site
Hi everybody,
most of us know the different places where time zones are to set in O365 - SharePoint Sites, ODFB, Users, etc. This is a mess...
I (Owner & Member) tried to set the time zone for a O365 Group Site via website-settings, but I got an access denied. Can anybody help me out, why I am not able to set the time zone?
Or is it possible via Powershell to set the time zone for (all) O365-Groups (or SharePoint-Sites, Users, ODFB, etc.)?
For ODFB, there is already a PS script in the OneDrive community - see https://techcommunity.microsoft.com/t5/OneDrive-for-Business/Timezone-setting-in-ODFB/m-p/7091#M153
Thanks!
You can use the below script for this.
To Get the time zone index values
https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
To get Locale ID
https://msdn.microsoft.com/en-us/library/ms912047(v=winembedded.10).aspx
$cred= Get-Credential $TimezoneValue= "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi"
$localeid = 5129 $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $Session #Add references to SharePoint client assemblies Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location) Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location) $Groups =Get-UnifiedGroup |Where-Object {$_.SharePointSiteUrl -ne $null}|select SharePointSiteUrl foreach($Group in $Groups.SharePointSiteUrl) { #Authenticate to Site $Username =$cred.UserName.ToString() $Password = $cred.GetNetworkCredential().Password $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force $Site = $Group $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site) $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$SecurePassword) $Context.Credentials = $Creds $TimeZones = $Context.Web.RegionalSettings.TimeZones $Context.Load($TimeZones) $Context.ExecuteQuery() #Changing the timezone $RegionalSettings = $Context.Web.RegionalSettings $Context.Load($RegionalSettings) $Context.ExecuteQuery() $TimeZone = $TimeZones | Where {$_.Description -eq $TimezoneValue} $RegionalSettings.TimeZone = $TimeZone
$RegionalSettings.Localeid = $localeid $Context.Web.Update() $Context.ExecuteQuery() Write-Host "Time Zone successfully updated for $($site) " }
- SanthoshB1Bronze Contributor
You can use the below script for this.
To Get the time zone index values
https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
To get Locale ID
https://msdn.microsoft.com/en-us/library/ms912047(v=winembedded.10).aspx
$cred= Get-Credential $TimezoneValue= "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi"
$localeid = 5129 $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $Session #Add references to SharePoint client assemblies Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location) Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location) $Groups =Get-UnifiedGroup |Where-Object {$_.SharePointSiteUrl -ne $null}|select SharePointSiteUrl foreach($Group in $Groups.SharePointSiteUrl) { #Authenticate to Site $Username =$cred.UserName.ToString() $Password = $cred.GetNetworkCredential().Password $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force $Site = $Group $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site) $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$SecurePassword) $Context.Credentials = $Creds $TimeZones = $Context.Web.RegionalSettings.TimeZones $Context.Load($TimeZones) $Context.ExecuteQuery() #Changing the timezone $RegionalSettings = $Context.Web.RegionalSettings $Context.Load($RegionalSettings) $Context.ExecuteQuery() $TimeZone = $TimeZones | Where {$_.Description -eq $TimezoneValue} $RegionalSettings.TimeZone = $TimeZone
$RegionalSettings.Localeid = $localeid $Context.Web.Update() $Context.ExecuteQuery() Write-Host "Time Zone successfully updated for $($site) " }- Salvatore BiscariSilver Contributor
Hi Santhosh. The script works perfectly. Thank you very much!
Nevertheless, some of my clients need to set the timezone interactively: do you know the reason behind the "Access denied" error and how to avoid it?
- SanthoshB1Bronze Contributor
Hi Salvatore Biscari, can you please try to add yourself as site collection admin and try again? This is the only case where the error you have mentioned occurs.
Set-SPOUser -Site https://contoso.sharepoint.com/sites/marketing -LoginName melissa.kerr@contoso.com -IsSiteCollectionAdmin $true
- Sravan BitlaCopper Contributor
Well done santosh, it works. Awesome :)
- Rob NicholsonBrass Contributor
Thanks for this script - going to be very useful for my UK clients. However, am I the only one who thinks that regional settings and timezones in Office 365 are just broken? Why are their regional settings per anything at all? Sure, I can show my client how to change from USA to UK time zone and UK formats, but why is this setting there at all? Surely the entire Office 365 suite esp. SharePoint should pick up my own regional settings in my profile and use that to adjust UTC dates to my local time zone and then the locale settings to decide how to display it?
How does all of this work for a global company where they have users in different time zones? Surely those in the USA want to know what the local time was when a UK user edited a file?
This has perplexed me since I start using Office 365 and now it's a bee in my bonnet. I see the original poster acknowledges this is a mess!
- Andreas SchlüterBrass ContributorThanks Santosh, that worked like a Charme!
- Great script SanthoshB1
- Salvatore BiscariSilver Contributor
Well, this morning I have been able to change interactively the time zone for some newly created groups. Hence it appears the inability was only a temporary glitch...
BTW, I found a way to interactively add an SCA to the Group site (as well as to every other site): if you add the string "/_layouts/mngsiteadmin.aspx" to the site address, you will get a page in which you can edit the SCA list.
- Yep,
You can still to this :-)
- Salvatore BiscariSilver Contributor
Why, in first place, does one get access denied when trying to set the timezone for an Office 365 Group?
Does someone know the answer?
- I'm not having such access denied error
- Salvatore BiscariSilver Contributor
Well, I am the Group owner (and tenant GA too...), I go to the Group, I go to Site Setting and then to International Settings, I change the Timezone, I click OK and I get Access denied. BTW in this case it is a private Group.
Can you reproduce this steps?
- Michal_KotekCopper Contributor
Only this solution WORKED for me:
https://chuvash.eu/2019/08/30/update-localeid-and-timezone-with-pnp/
I was finally to change LocaleID on my existing Sharepoint site for correct formula language in Excel Online files.
Sharepoint LocalZones ID here
https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/jj171282(v%3Doffice.15)