Tuesday, January 21, 2014

People and group field is imported as Single line of text field when imported as spreadsheet

Issue: When we create a list using import a spreadsheet and if you have an people and group field in the spreadsheet, after import the people and group field may change as single line of text field.

Workaround: Create a people and group field in the same list where you have imported the list.Following PowerShell script will read the values from single line of text field and update in the value in people and group field. Make sure your AD user profile is similar to the source list/site.

Add-PSSnapin Microsoft.Sharepoint.Powershell
$site = new-object Microsoft.SharePoint.SPSite("SiteURL”)
$web =  Get-SPWeb -Identity siteURL
$lista =$web.Lists["ListName"]
$items = $lista.items
foreach ($item in $items) {
  $user = $item["SingleTextColumnNameOfUserName"]
  write-host $useracc 
$useracc =  $web.EnsureUser( $user); 
$item["NewPeople&GroupFieldName"] = $useracc
write-host $useracc


1 comment:

  1. In order for you to run this snapin you would either need to be on one of the SharePoint servers or accessed in where the snapin is available.