Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to update Column value in a list using powershell.

$
0
0

Hi All,

I am trying to copy value of One column to another column in same list. I am using SPSiteDataQuery for this. I am using following power shell script.

if ((Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PSSnapin Microsoft.SharePoint.Powershell

}
 $CopyFromColumnName1 = "Section-1 Summary" #column copy source 1

 $CopyToColumnName1 = "RichTextBoxControl"  #destination column 1

$siteCollectionUrl = http://someURL
$site =new-object Microsoft.SharePoint.SPSite($siteCollectionUrl)
$query = new-object Microsoft.SharePoint.SPSiteDataQuery

$query.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='PublishingPageLayout' /><FieldRef Name='FileLeafRef' /><FieldRef Name='RTC' /><FieldRef Name='SummaryOne' />";
$query.Webs = "<Webs Scope='SiteCollection'>"

$query.Lists = "<Lists ServerTemplate='850'/>"
$query.Query = "<Where>
                    <Contains>
                        <FieldRef Name='PublishingPageLayout' />
                        <Value Type='URL'>SomePageLayout</Value>
                    </Contains>
                </Where>"
$spListItems = $site.rootweb.GetSiteData($query)
#Write-Host $spListItems
foreach($row in $spListItems.Rows)
{
  $row.RTC = $row.SummaryOne
  write-Host $row.RTC
  $childWeb.Dispose()
}
$site.Dispose()

Here the column RTC is not updating on executing the script. I want to copy data from "SummaryOne" to "RTC" column.

Please assist me with this issue.


amol


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>