I want to rename a column which is associated to Content Type i used the following to update all the columns which contains the column in the list but forgot to update the column name in the content type and not sure how to approach it
$SiteURL = "http://pnpdemo" $OldColumnName ="Target Folder" $NewColumnName ="New Target Folder"
$site = Get-SPSite $SiteURL foreach ($web in $site.AllWebs) {
$ListsToProcess= @()
$Lists = $web.Lists
foreach ($list in $lists)
{
foreach ($column in $list.Fields)
{
if ($column.Title -eq $OldColumnName)
{
Write-Host "Found the Column in list: " $list.Title " at "$web.Url
#Send it to an Array
$ListsToProcess+=$List
}
}
}
foreach ($list in $ListsToProcess) {
$column = $list.fields | where {$_.Title -eq $OldColumnName}
$column.Title = $NewColumnName
$column.Update()
} $web.Dispose() } $site.Dispose()