Tuesday, August 2, 2011

Update content type filed in the shareponit 2010 list using powershell script

$siteUrl = "http://servername/sites/P127036/"
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$RootWeb = $site.RootWeb
$EventsList ="MyList"
  if ($EventsList -ne $null)
   {
        $MissionContentType = $EventsList.ContentTypes["Mission"]
  $field = $MissionContentType.FieldLinks["Category"]  # here u shuld not take Field
  $field.Hidden = $true
  $MissionContentType.Update();
  $EventsList.Update()
}
# Dispose the site object
if ($site) {$site.Dispose()}
if ($RootWeb){ $RootWeb.Dispose()}

No comments:

Post a Comment

Followers

Blog Archive