0
votes

I am trying to Add Alternative Language to my SharePoint sites using PowerShell:

$sitetenant = "https://mytenat-admin.sharepoint.com"
$credential = Get-Credential
Connect-SPOService -Url $sitetenant -Credential $credential
$sites = Get-SPOSite "https://mytenat.sharepoint.com/site"

foreach($site in $sites) 
{
      $culture = New-Object System.Globalization.CultureInfo(1033)
      $site.AddSupportedUICulture($culture)
      $site.Update()
}

I think this method doesn't exist in SharePoint Online?

1
Open the RootWeb of the site collection and pass the LCID of your desired language to AddSupportedUICulture method. E.g. $web = $site.OpenWeb(); $web.AddSupportedUICulture(1031) - Peter Schneider

1 Answers

0
votes

SharePoint Online Management Shell cmdlets are pretty limited in this regard, i would suggest to utilize CSOM API, in particular Web.AddSupportedUILanguage method to add alternative language as demonstrated below:

$siteUrl = "https://contoso.sharepoint.com/"
$UserName = "[email protected]"
$Password = ""


$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$ctx.Credentials = $credentials

$web = $ctx.Site.RootWeb
$lcid = 1049
$web.AddSupportedUILanguage($lcid)
$web.Update()
$ctx.ExecuteQuery()