Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向SharePoint Online Sites PowerShell添加替代语言_Powershell_Sharepoint_Office365_Sharepoint Online - Fatal编程技术网

向SharePoint Online Sites PowerShell添加替代语言

向SharePoint Online Sites PowerShell添加替代语言,powershell,sharepoint,office365,sharepoint-online,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($s

我正在尝试使用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中不存在此方法?

cmdlet在这方面非常有限,我建议使用CSOM API,特别是添加替代语言,如下所示:

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

打开网站集的RootWeb,并将所需语言的LCID传递给AddSupportedCulture方法。例如,
$web=$site.OpenWeb()$web.addSupportedUlture(1031)