Tuesday, August 2, 2011

Rename Content type name in the list using Powershell

$siteUrl = "http://servername/sites/P127036/"
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$RootWeb = $site.RootWeb

$lookForList ="Tasks"
$TaskList= $RootWeb.Lists[$lookForList]
   
    if ($TaskList -ne $null)
    {
        $TaskContentType = $TaskList.ContentTypes["Custom Tasks"]

  if ($TaskContentType -ne $null)
  {
     $TaskContentType.Name = "Tasks"
     $TaskContentType.Update()
  }
  
}

# Dispose the site object if ($site) {$site.Dispose()}if ($RootWeb){ $RootWeb.Dispose()}

No comments:

Post a Comment

Followers

Blog Archive