Advertisement
Guest User

SPO Region

a guest
Aug 1st, 2018
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # https://techcommunity.microsoft.com/t5/Office-365-Groups/Time-Zone-Settings-for-O365-Groups-SharePoint-Site/td-p/26301
  2. # https://blogs.technet.microsoft.com/heyscriptingguy/2014/04/24/create-and-manage-sharepoint-online-sites-by-using-powershell/
  3. # Requires https://www.microsoft.com/en-ie/download/details.aspx?id=35585 to run
  4. #Links to investigate
  5.  
  6.  
  7. $TimezoneValue= "(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London"
  8. $localeid = 2057
  9.  
  10. $AuthStore = "\\fcitapps\ProgramStore\UserCreation\Credentials\" + $env:USERNAME
  11. $Auth = Get-Content $AuthStore | ConvertTo-SecureString
  12. $O365Username = $env:USERNAME + "@domain.com"
  13. $LocalUsername = "DOMAIN\" + $env:USERNAME
  14.  
  15. #Create a credential with your username and retrieved password.
  16. $O365Cred = New-Object System.Management.Automation.PsCredential($O365Username, $Auth)
  17. $LocalCred = New-Object System.Management.Automation.PsCredential($LocalUsername, $Auth)
  18.  
  19. #Generate a new Office 365 Powershell session.
  20. $s2=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $O365Cred -Authentication Basic -AllowRedirection
  21. Import-PSSession -Session $s2
  22.  
  23. #Load the Sharepoint prerequisites
  24. Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
  25. Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)
  26.  
  27. #Create credentials for connecting to Sharepoint sites
  28. $SPOUsername = "globaladmin@domain.com"
  29. $SPOPassword = Read-Host -Prompt "Enter password for $SPOUsername" -AsSecureString
  30. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($SPOUsername,$SPOPassword)
  31.  
  32. #Load all the Sharepoint groups
  33. $Groups =Get-UnifiedGroup |Where-Object {$_.SharePointSiteUrl -ne $null}|select SharePointSiteUrl
  34.  
  35. foreach($Group in $Groups.SharePointSiteUrl)
  36. {
  37. Write-Host $Group
  38.  
  39. $Site = $Group
  40. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
  41. $Context.Credentials = $Creds
  42.  
  43.  
  44.  
  45.  
  46. $TimeZones = $Context.Web.RegionalSettings.TimeZones
  47.  
  48. Try{
  49. $Context.Load($TimeZones)
  50. $Context.ExecuteQuery()
  51. $RegionalSettings = $Context.Web.RegionalSettings
  52. $Context.Load($RegionalSettings)
  53. $Context.ExecuteQuery()
  54. Write-Host $RegionalSettings.LocaleID
  55. Try{
  56. $TimeZone = $TimeZones | Where {$_.Description -eq $TimezoneValue}
  57. $RegionalSettings.TimeZone = $TimeZone
  58. $RegionalSettings.Localeid = $localeid
  59. $Context.Web.Update()
  60. $Context.ExecuteQuery()
  61. Write-Host "Changed"
  62. }
  63. Catch{
  64. Write-Host $Error[0] -ForegroundColor Red
  65. Write-Host "Unable to modify"
  66. }
  67.  
  68. }
  69. Catch{
  70. Write-Host "Unauthorised" -ForegroundColor Red
  71. }
  72.  
  73.  
  74. Write-Host "----------"
  75.  
  76. }
  77.  
  78. Get-PSSession | Remove-PSSession
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement