SharePoint: Add existing field to content type using PowerShell
This PowerShell Script is used for add existing site field or column to a content type: cls
Remove-PSSnapin Microsoft.SharePoint. Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint. Powershell
$site = Get-SPSite -Identity "Your Site Url"
$web = $site.RootWeb
$ct=$web.ContentTypes[" ContentType"];
$fieldAdd=$web.Fields[" Field Name"]
$fieldLink=New-Object Microsoft.SharePoint. SPFieldLink($fieldAdd)
$ct.FieldLinks.Add($fieldLink) ;
$ct.Update()
$web.Dispose()
$site.Dispose()
Remove-PSSnapin Microsoft.SharePoint.
Add-PSSnapin Microsoft.SharePoint.
$site = Get-SPSite -Identity "Your Site Url"
$web = $site.RootWeb
$ct=$web.ContentTypes["
$fieldAdd=$web.Fields["
$fieldLink=New-Object Microsoft.SharePoint.
$ct.FieldLinks.Add($fieldLink)
$ct.Update()
$web.Dispose()
$site.Dispose()
Comments
Post a Comment