SharePoint Online CSOM Update Region Settings

Just a quick post with an example of how to update a SharePoint Online Site Collection’s Region settings via SharePoint Online Management Shell.

  • First, set up your ClientContext in the normal manner:
$Password = ConvertTo-SecureString -String "yourPassword" -AsPlainText -Force;
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/sites/yourSiteCollection");
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("user@company.com, $Password);
  • Now we need to set up our target web site object:
$web = $ctx.Web;
$ctx.Load($web);
$ctx.ExecuteQuery();
  • Next, update the settings. In this example, I’m setting the LocaleId to 2057 (en-UK)
$web.RegionalSettings.LocaleId = 2057;
$web.Update();
  • Finally, run the ExecuteQuery method to apply the changes:
$ctx.ExecuteQuery();

 

References

  • Locale Identity (LCID): https://msdn.microsoft.com/en-gb/goglobal/bb964664
  • ClientContext.Web Property: https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.client.clientcontext.web.aspx

About the author