Migrate data from CSV to SharePoint List – PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

$FilePathCSV = import-csv D:\Book1.csv

$webURL = "http://url"
$listName = "CSVInput"
$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]

foreach($CurrentRwo in $FilePathCSV)
$field1 = $CurrentRwo.Name
$field2 = $CurrentRwo.Age

$newItem = $list.Items.Add()
$newItem["Title"] = $field1
$newItem["Age"] = $field2

$filebytes = [System.IO.File]::ReadAllBytes("D:\Book1.csv")
$newItem.Attachments.Add("DummyFile Title",$filebytes)



About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

Comments are closed.

%d bloggers like this: