Clear-Host
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
$web=Get-SPWeb "http://site:1234"
function cleanFieldLinks($listName){
$list = $web.GetList($listName)
ForEach($ctype in $list.ContentTypes){
write-host $ctype.Name": "$ctype.ID
$ct = $ctype
$flDub = $ct.FieldLinks | group-object DisplayName | where { $_.Count -gt 1 }
foreach($fl in $flDub) {
$skipFirst = $fl.Group | select-object -skip 1
foreach($flDel in $skipFirst){
$ct.FieldLinks.Delete($flDel.Id)
}
}
$ct.Update()
}
}
cleanFieldLinks("/Library")
$web.Dispose()
Source
No comments:
Post a Comment