向SharePoint Online Sites PowerShell添加备用语言

时间:2017-05-24 14:38:58

标签: powershell sharepoint office365 sharepoint-online

我正在尝试使用PowerShell向我的SharePoint网站添加替代语言:

$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()
}

我认为SharePoint Online中不存在此方法吗?

1 个答案:

答案 0 :(得分:0)

SharePoint Online Management Shell cmdlet在这方面非常有限,我建议使用CSOM API,特别是Web.AddSupportedUILanguage method添加替代语言,如下所示:

$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()