I have added a new column in library in SharePoint 2010 site using powershell. The column is getting added, however content type is not getting updated for the libraries. When I try to get new column in workflow, it is not showing up. Any advise on this?
I have used below script:
$ver = $host | select version
if($Ver.version.major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ea 0))
{
Write-Progress -Activity "Loading Modules" -Status "Loading Microsoft.SharePoint.PowerShell"
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$SourceWebURL = "http://sitecollection/sites/site"
$ssite = Get-SPSite $SourceWebURL
$sweb = $ssite.OpenWeb("subsite")
for ($i = 0; $i -lt $sweb.Lists.Count; $i++)
#foreach($sList in $sweb.Lists)
{
$sList = $sweb.Lists[$i];
if($sList.BaseType -eq "DocumentLibrary")
{
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text
$sList.Fields.Add("Name",$spFieldType,$false)
$sList.Update()
$f = $sList.Fields["Name"]
$f.DefaultValue =$sList.Title
$f.Update()
}
}