向SharePoint Online Sites PowerShell添加替代语言
我正在尝试使用PowerShell向SharePoint网站添加其他语言:向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
$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)