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()
  

Comments

Popular posts from this blog

C# Copy files from one server to another

Export SharePoint Online Group Users to Excel using Powershell