Office 365: How to change regional settings for all the Groups sites in Office 365 using PowerShell!

This time I’m sharing a PowerShell script that allows to change regional settings for all the Groups sites in Office 365 using PowerShell. You can download the script from the following location: How to set regional settings for all the Office 365 Groups sites in a tenant

############################################################################################################################################
# Script that allows to change regional settings for all the Office 365 Groups sites in a tenant
# Required Parameters:
#  -> $sUserName: User Name to connect to the SharePoint Online Site.
#  -> $sPassword: Password for the user.
#  -> $sSiteUrl: SharePoint Online Site.
#  -> $sTimezoneValue: Time Zone.
#  -> $ilocaleid: Locale ID.
############################################################################################################################################

$host.Runspace.ThreadOptions = "ReuseThread"

#Definition of the function that allows to change regional settings on SPO Site
function Change-RegionalSettings
{
    param ($sSiteUrl,$sUserName,$sPassword,$sCSOMPath,$sTimezoneValue,$ilocaleid)
    try
    {           
        #Adding the Client OM Assemblies        
        $sCSOMRuntimePath=$sCSOMPath +  "\Microsoft.SharePoint.Client.Runtime.dll"        
        $sCSOMPath=$sCSOMPath +  "\Microsoft.SharePoint.Client.dll"
                     
        Add-Type -Path $sCSOMPath         
        Add-Type -Path $sCSOMRuntimePath        

        #SPO Client Object Model Context
        $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl) 
        $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)  
        $spoCtx.Credentials = $spoCredentials 

        $spoTimeZones = $spoCtx.Web.RegionalSettings.TimeZones       
        $spoCtx.Load($spoTimeZones)
        $spoCtx.ExecuteQuery()
        $spoTimeZone = $spoTimeZones | Where {$_.Description -eq $sTimezoneValue}
        $spoRegionalSettings = $spoCtx.Web.RegionalSettings      
        $spoCtx.Load($spoRegionalSettings)
        $spoCtx.ExecuteQuery()        
        If ($spoRegionalSettings.LocaleId -ne $ilocaleid) {
            $spoRegionalSettingsValue=$spoRegionalSettings.LocaleId.ToString()
            Write-Host "----------------------------------------------------------------------------"  -ForegroundColor Green
            Write-Host "Updating Regional Settings from $spoRegionalSettingsValue to $ilocaleid" -ForegroundColor Green
            Write-Host "----------------------------------------------------------------------------"  -ForegroundColor Green
            $spoRegionalSettings.TimeZone = $spoTimeZone
            $spoRegionalSettings.Localeid = $ilocaleid
            $spoCtx.Web.Update()
            $spoCtx.ExecuteQuery()
        }

    }
    catch [System.Exception]
    {
        Write-Host -ForegroundColor Red $_.Exception.ToString()   
    }    
}

#Definition of the function that get the Groups Sites which local settings have to be updated
function Get-Office365GroupSites
{
   param ($Office365Credentials,$sUserName,$sPassword,$sCSOMPath,$sTimezoneValue,$ilocaleid)
    try
    {  
    $EXOSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Office365Credentials  -Authentication Basic -AllowRedirection 
    Import-PSSession $EXOSession
    $O365Groups = (Get-UnifiedGroup | ? {$_.SharePointSiteUrl -ne $Null} | Select SharePointSiteUrl, DisplayName, Alias)
    ForEach ($O365Group in $O365Groups) {  
         Write-Host "Processing" $O365Group.DisplayName "site" $O365Group.SharePointSite
             Change-RegionalSettings -sSiteUrl $O365Group.SharePointSiteUrl -sUserName $sUserName -sPassword $sPassword -sCSOMPath $sCSOMPath -sTimeZoneValue $sTimezoneValue -iLocaleID $ilocaleid
         }
    }
    catch [System.Exception]
    {
        Write-Host -ForegroundColor Red $_.Exception.ToString()   
    }    
}

$sTimezoneValue= "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris"
$ilocaleid = 1033 
$sCSOMPath="F:\03 Docs\07 MVP\03 MVP Work\11 PS Scripts\Office 365\SPO CSOM\Dec 2016"
$sUserName = "<Office365_User>"
$sMessage="Introduce your SPO Credentials"
$Office365Credentials = Get-Credential -UserName $sUserName -Message $sMessage
$sPassword= $Office365Credentials.GetNetworkCredential().Password | ConvertTo-SecureString -AsPlainText -Force 

Get-Office365GroupSites -Office365Credentials $Office365Credentials -sUserName $sUserName -sPassword $sPassword -sCSOMPath $sCSOMPath -sTimezoneValue $sTimezoneValue -ilocaleid $ilocaleid


Office 365: Como configurar las configuraciones regionales de todos los Sitios de Grupos de Office 365 con PS!

En esta ocasión os comparto un script PowerShell que permite cambiar las configuraciones regionales de todos los sitios de Grupos de Office 365. El script en cuestión es el siguiente: How to set regional settings for all the Office 365 Groups sites in a tenant

############################################################################################################################################
# Script that allows to change regional settings for all the Office 365 Groups sites in a tenant
# Required Parameters:
#  -> $sUserName: User Name to connect to the SharePoint Online Site.
#  -> $sPassword: Password for the user.
#  -> $sSiteUrl: SharePoint Online Site.
#  -> $sTimezoneValue: Time Zone.
#  -> $ilocaleid: Locale ID.
############################################################################################################################################

$host.Runspace.ThreadOptions = "ReuseThread"

#Definition of the function that allows to change regional settings on SPO Site
function Change-RegionalSettings
{
    param ($sSiteUrl,$sUserName,$sPassword,$sCSOMPath,$sTimezoneValue,$ilocaleid)
    try
    {           
        #Adding the Client OM Assemblies        
        $sCSOMRuntimePath=$sCSOMPath +  "\Microsoft.SharePoint.Client.Runtime.dll"        
        $sCSOMPath=$sCSOMPath +  "\Microsoft.SharePoint.Client.dll"
                     
        Add-Type -Path $sCSOMPath         
        Add-Type -Path $sCSOMRuntimePath        

        #SPO Client Object Model Context
        $spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl) 
        $spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)  
        $spoCtx.Credentials = $spoCredentials 

        $spoTimeZones = $spoCtx.Web.RegionalSettings.TimeZones       
        $spoCtx.Load($spoTimeZones)
        $spoCtx.ExecuteQuery()
        $spoTimeZone = $spoTimeZones | Where {$_.Description -eq $sTimezoneValue}
        $spoRegionalSettings = $spoCtx.Web.RegionalSettings      
        $spoCtx.Load($spoRegionalSettings)
        $spoCtx.ExecuteQuery()        
        If ($spoRegionalSettings.LocaleId -ne $ilocaleid) {
            $spoRegionalSettingsValue=$spoRegionalSettings.LocaleId.ToString()
            Write-Host "----------------------------------------------------------------------------"  -ForegroundColor Green
            Write-Host "Updating Regional Settings from $spoRegionalSettingsValue to $ilocaleid" -ForegroundColor Green
            Write-Host "----------------------------------------------------------------------------"  -ForegroundColor Green
            $spoRegionalSettings.TimeZone = $spoTimeZone
            $spoRegionalSettings.Localeid = $ilocaleid
            $spoCtx.Web.Update()
            $spoCtx.ExecuteQuery()
        }

    }
    catch [System.Exception]
    {
        Write-Host -ForegroundColor Red $_.Exception.ToString()   
    }    
}

#Definition of the function that get the Groups Sites which local settings have to be updated
function Get-Office365GroupSites
{
   param ($Office365Credentials,$sUserName,$sPassword,$sCSOMPath,$sTimezoneValue,$ilocaleid)
    try
    {  
    $EXOSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Office365Credentials  -Authentication Basic -AllowRedirection 
    Import-PSSession $EXOSession
    $O365Groups = (Get-UnifiedGroup | ? {$_.SharePointSiteUrl -ne $Null} | Select SharePointSiteUrl, DisplayName, Alias)
    ForEach ($O365Group in $O365Groups) {  
         Write-Host "Processing" $O365Group.DisplayName "site" $O365Group.SharePointSite
             Change-RegionalSettings -sSiteUrl $O365Group.SharePointSiteUrl -sUserName $sUserName -sPassword $sPassword -sCSOMPath $sCSOMPath -sTimeZoneValue $sTimezoneValue -iLocaleID $ilocaleid
         }
    }
    catch [System.Exception]
    {
        Write-Host -ForegroundColor Red $_.Exception.ToString()   
    }    
}

$sTimezoneValue= "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris"
$ilocaleid = 1033 
$sCSOMPath="F:\03 Docs\07 MVP\03 MVP Work\11 PS Scripts\Office 365\SPO CSOM\Dec 2016"
$sUserName = "<Office365_User>"
$sMessage="Introduce your SPO Credentials"
$Office365Credentials = Get-Credential -UserName $sUserName -Message $sMessage
$sPassword= $Office365Credentials.GetNetworkCredential().Password | ConvertTo-SecureString -AsPlainText -Force 

Get-Office365GroupSites -Office365Credentials $Office365Credentials -sUserName $sUserName -sPassword $sPassword -sCSOMPath $sCSOMPath -sTimezoneValue $sTimezoneValue -ilocaleid $ilocaleid


Office 365: New version of the SPO Management Shell (April 2018) released!

Microsoft has just released a new version of the SharePoint Online (SPO) Management Shell that can be downloaded from the following URL:

https://www.microsoft.com/en-us/download/details.aspx?id=35588

With this release, the number of SPO cmdlets has increased to 135.

Some of the new cmdlets included are the following ones (Note: Don’t expect this cmdlets will work yet since they realy on features not ready yet in SPO):

Office 365: Disponible la actualización de abril de 2018 del SPO Management Shell!

Microsoft acaba de liberar una nueva actualización del SharePoint (SPO) Management Shell que podéis descargar desde el siguiente enlace:

https://www.microsoft.com/en-us/download/details.aspx?id=35588

Con esta release, pasamos a tener 135 cmdelts para SPO!! Entre los comandos nuevos nos encontraremos (Nota: La mayoría no van a funcionar):

Office 365: April 2018 version of SPO CSOM just released!

As you can read at Office Dev Blog, Microsoft has just released a new edition of the Client Side Object Model (CSOM) for SharePoint Online (SPO). You can read the full announcement here: https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-april-2018

As always, this new CSOM version (16.1.7618.1200) is available via NuGet