ShellScript:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = New-Object Microsoft.SharePoint.SPSite("http://sitecollection URL")
$web=$site.OpenWeb()
if ($web -ne $Null)
{
$AverageRating=$web.Fields[[System.Guid]"5a14d1ab-1513-48c7-97b3-657a5ba6c742"]
$RatingCount=$web.Fields[[System.Guid]"b1996002-9167-45e5-a4df-b2c41c6723c7"]
$PagesList=$web.lists["Pages"]
if ($PagesList -ne $Null)
{
Write-Host " Processing List : " $PagesList.Title
$ct=$PagesList.ContentTypes["Page"]
If ($ct -ne $null)
{
Write-Host " Adding Rating columns to content type : " $ct.name
$AverageRatinglink = new-object Microsoft.SharePoint.SPFieldLink $AverageRating
$RatingCountLink = new-object Microsoft.SharePoint.SPFieldLink $RatingCount
$ct.FieldLinks.Add($AverageRatinglink)
$ct.FieldLinks.Add($RatingCountLink)
$ct.update()
}
}
}
$web.Dispose()
Comments
Post a Comment