In Focus

How to set the default content type using powershell

In this blog we will be seeing how to set the default content type using powershell


$site=Get-SPSite "http://serverName:1111/"
$web=$site.RootWeb
$list=$web.Lists["Shared Documents"]    
$currentOrder = $list.ContentTypes
$result=New-Object System.Collections.Generic.List[Microsoft.SharePoint.SPContentType]
foreach ($ct in $currentOrder)
{
 if ($ct.Name.Contains("_CustomContentType"))
 {
   $result.Add($ct)
 }
}
$list.RootFolder.UniqueContentTypeOrder = $result
$list.RootFolder.Update()