Friday 23 May 2014

Add Alternative Languages using PowerShell / Add Supported Languages using Powershell



Below is the script to Add Alternative Language to all SiteCollections in a WebApplication.

We have set English as Supported/ Alternative language if the site was created in other Language.

Site Locale code of en-us is 1033

cls

$webapp=Get-SPWebApplication   "http://sedwdevrtm:22222"

$sitecollection= $webapp.Sites.url


foreach($sites in $sitecollection)
{

$web =Get-SPWeb -Identity $sites

$webCul=$web.UICulture

try
{
    if($webCul.LCID -eq "1033")
    {

       Write-Host " English is Set as default Language so no need to change"
       
    }
    elseif ($webCul.LCID -ne "1033" -and $web.IsMultilingual -eq $false)
    {
        $web.IsMultilingual=$true
        $web.AddSupportedUICulture(1033)
        $web.Update()
        Write-Host $web "Alternative Language added Succesfully "
   
    }
   

    elseif($web.IsMultilingual -eq $true -and  !($web.SupportedUICultures.Contains(1033)) )
    
       {
          $web.AddSupportedUICulture(1033);
          $web.Update();
          Write-Host $web "Alternative Language added Succesfully "
        }
     
    
     $web.Dispose()
 }
catch
{
     $ErrorMessage = $_.Exception.Message

     Write-Host $web.Title "Not executed" $ErrorMessage

}

}


No comments:

Post a Comment