Hi, @Diane Walters ,
It may be better to use PowerShell to finish the process in bulk. Here is a CSOM script below which you can manually add all the list names inside. Replace the placeholders and run the script in PowerShell. It works for the situation where you only want to add the site column to certain libraries.
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Function Add-SiteColumnToLibrary()
{
param
(
[Parameter(Mandatory=$true)] [string] $LibraryName,
[Parameter(Mandatory=$true)] [string] $SiteColumnName
)
Try{
#Get the Site column
$SiteColumnColl = $Ctx.Web.Fields
$Ctx.Load($SiteColumnColl)
$Ctx.ExecuteQuery()
$SiteColumn = $SiteColumnColl | Where {$_.Title -eq $SiteColumnName}
#Check if given site column exists
if($SiteColumn -eq $Null)
{
Write-host "Site Column '$SiteColumnName' doesn't exists!" -f Yellow
Return
}
Else
{
#Get the list
$List=$Ctx.Web.Lists.GetByTitle($LibraryName)
#Get the Site column
$Field = $Web.Fields.GetByTitle($SiteColumnName)
#Add the site column to the list
$List.Fields.Add($Field)
$ctx.ExecuteQuery()
}
Write-host "Site Column '$SiteColumnName' Added to the library '$LibraryName' Successfully!" -f Green
}
Catch {
write-host -f Red "Error Adding Site Column to Content Type!" $_.Exception.Message
}
}
#Variables
$SiteURL="<site URL>"
$LibraryNames=@("<LibraryName1>", "<LibraryName1>", "<LibraryName1>")
$SiteColumnName="<Site Column Name>"
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Web = $Ctx.web
#Call the function to add site column to document libraries
foreach($LibraryName in $LibraryNames)
{
Add-SiteColumnToLibrary -LibraryName $LibraryName -SiteColumnName $SiteColumnName
}
I am not sure whether you have a csv file holding all the library names or you are doing the process for all libraries in your site. Have a try with the script first. If that does not work for you, please let know more information about how you pick up the libraries.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.