简体   繁体   中英

Add alternative language to SharePoint Online Sites PowerShell

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?

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 = "username@contoso.onmicrosoft.com"
$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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM