Copy SharePoint List Column Values from One to Another using PowerShell
Requirement: Copy Column Values from One to Another in SharePoint
In some situations, we may have to copy SharePoint list column values from one column to another. Say, for E.g.
PowerShell to Copy Column Values from one to another in SharePoint
Here is the PowerShell script to copy SharePoint list / library field data from one column to another column:
In some situations, we may have to copy SharePoint list column values from one column to another. Say, for E.g.
- OOTB column doesn't provide a way to enter more than 255 characters in Multiple Lines of Text field. As user already entered values in it and wants to make it allow more than 255 chars.
- When a SharePoint field's internal name needs to be changed.
- There is requirement to add a new column, whose values are partially based on an existing column
PowerShell to Copy Column Values from one to another in SharePoint
Here is the PowerShell script to copy SharePoint list / library field data from one column to another column:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #Using Get-SPSite in MOSS 2007 function global:Get-SPSite($url) { return new-Object Microsoft.SharePoint.SPSite($url) } Function global:Get-SPWeb($url) { $site= New-Object Microsoft.SharePoint.SPSite($url) if($site -ne $null) { $web=$site.OpenWeb(); } return $web } #Parameters $web = Get-SPweb "http://sharepoint.crescent.com/" $listName = "Pictures" #Use the Display Names $CopyFromColumnName = "Description" #column copy source $CopyToColumnName = "Desc" #destination column #Get the List $list = $web.lists[$ListName] #Get all Items $Items = $list.Items foreach ($Item in $items) { #copy data from one column to another $item[$copyToColumnName] = $item[$copyFromColumnName] #Do a system update to avoid Version and to Keep same metadata $item.SystemUpdate($false) }
Copy SharePoint List Column Values from One to Another using PowerShell
Reviewed by Salaudeen Rajack
on
January 25, 2014
Rating:

No comments:
Please Login and comment to get your questions answered!