SOLVED

Time Zone Settings for O365 Groups SharePoint-Site

Brass Contributor

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!

32 Replies
best response confirmed by Andreas Schlüter (Brass Contributor)
Solution

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) " }

 

 

 

Thanks Santosh, that worked like a Charme!

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?

 

 

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

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?

I have just done over the same Group that was Public but I change to Private before making the changes in the regional settings

@Gary Martin Thanks for letting me know this. I have edited the script accordingly. 

Santhosh - That sorted my date format - thanks a lot for the quick response. Solved something that would have become a major irritation.

For me it gives access denied if I try to change the timezone for both public and private groups.

Any ideas?

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?

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 

 

Thanks Santhosh, but unfortunately it doesn't work.

It looks like you cannot add a collection admin to a Group site...

Ey @Salvatore Biscari I think something is wrong with this Group I have just executed a similar PS to the one provied by @SanthoshB1 and I worked perfectly...so perfectly that I was able to add as Group Site Administrator a user that it's not a member of the Groupe neither an owner

$sSiteCollectionAdmin="dave@nuberosnet.onmicrosoft.com"
$GroupUrl="https://nuberosnet.sharepoint.com/sites/minioms/"
Set-SPOUser -Site $GroupUrl -LoginName $sSiteCollectionAdmin -IsSiteCollectionAdmin $true

Hi @Juan Carlos González Martín.

What was exactly the output you got after executing the script? I mean, how did you confirm it worked?

I am under the impression that it appears to work but it doesn't actually work...

Of course, see my screenshot :-). Fortunately I have not closed my PowerShell session :)

Set_User_Group_Site_Admin.PNG

 

 

Thank you very much!

I had the same output, but in practice I had no effect, meaning that I am still not able to change the timezone...

Also, Get-SPOUser doesn't work...

How can we confirm positively that Set-SPOUser worked?

Mmmm...strange, no issues on my side with this Group...I might do some more further testing on other Groups or even other tenants
1 best response

Accepted Solutions
best response confirmed by Andreas Schlüter (Brass Contributor)
Solution

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) " }

 

 

 

View solution in original post