Forum Discussion
Time Zone Settings for O365 Groups SharePoint-Site
- 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) " }
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
- 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...
- Nov 18, 2016
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
- Salvatore BiscariNov 18, 2016Silver Contributor
Hi jcgonzalezmartin.
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...