Nov 02 2016 04:17 AM
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!
Nov 02 2016 05:00 AM - edited Nov 16 2016 10:34 PM
SolutionYou 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) " }
Nov 02 2016 11:38 PM
Nov 03 2016 06:41 AM
Nov 16 2016 09:19 AM
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?
Nov 16 2016 09:32 AM
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?
Nov 16 2016 01:44 PM
Nov 16 2016 01:58 PM
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?
Nov 16 2016 02:01 PM
Nov 16 2016 10:36 PM
@Gary Martin Thanks for letting me know this. I have edited the script accordingly.
Nov 16 2016 11:42 PM
Santhosh - That sorted my date format - thanks a lot for the quick response. Solved something that would have become a major irritation.
Nov 17 2016 03:18 AM
For me it gives access denied if I try to change the timezone for both public and private groups.
Any ideas?
Nov 17 2016 04:28 AM
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?
Nov 17 2016 09:38 PM
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
Nov 18 2016 07:53 AM
Thanks Santhosh, but unfortunately it doesn't work.
It looks like you cannot add a collection admin to a Group site...
Nov 18 2016 08:19 AM
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
Nov 18 2016 10:05 AM - edited Nov 18 2016 10:56 AM
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...
Nov 18 2016 11:10 AM
Of course, see my screenshot :-). Fortunately I have not closed my PowerShell session 🙂
Nov 18 2016 11:16 AM - edited Nov 18 2016 11:17 AM
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?
Nov 18 2016 11:17 AM
Nov 02 2016 05:00 AM - edited Nov 16 2016 10:34 PM
SolutionYou 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) " }