Forum Discussion
Andreas Schlüter
Nov 02, 2016Brass Contributor
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 fo...
- Nov 02, 2016
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) " }
SanthoshB1
Nov 02, 2016Bronze 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) " }
- Sravan BitlaMar 14, 2017Copper Contributor
Well done santosh, it works. Awesome :)
- Rob NicholsonJul 21, 2017Brass 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!
- R NaylorDec 19, 2017Brass Contributor
The more I'm using new 365 features like Groups and Teams, the more I'm coming across this complete cluster-f*%^ that is regional settings. It has not been thought through at all by Microsoft. The world seems to start and end in the United States, completely ignoring anyone with a regional setting anywhere else that the US. The amount of different places where it is wrong is staggering, even between things that are supposed to be unified such as a O365 Group and Modern Team site.
- Salvatore BiscariNov 17, 2016Silver 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?
- SanthoshB1Nov 18, 2016Bronze 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
- Salvatore BiscariNov 18, 2016Silver Contributor
Thanks Santhosh, but unfortunately it doesn't work.
It looks like you cannot add a collection admin to a Group site...
- Gary MartinNov 16, 2016Copper Contributor
Santosh
Thanks for the script - worked perfectly and solved the issue for me. Having trouble with adapting it to work for the Localeid. Could you point me in the right direction?
- SanthoshB1Nov 17, 2016Bronze Contributor
Gary Martin Thanks for letting me know this. I have edited the script accordingly.
- Gary MartinNov 17, 2016Copper Contributor
Santhosh - That sorted my date format - thanks a lot for the quick response. Solved something that would have become a major irritation.
- Andreas SchlüterNov 03, 2016Brass ContributorThanks Santosh, that worked like a Charme!