Powershell Import Data from csv to sharepoint 2013 list with special characters

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue ############## PARAMETERS #################### $WebUrl = "Enter the sitecollection url" $Listname = "Enter the Listname" #Convert CSV to UTF-8 with special characters Get-Content E:\Tempfolder\testCSV.csv | Out-File E:\Tempfolder\testCSV.csv -Encoding utf8 #Get the CSV file and connect to the SharePoint list $DataSet = import-csv -Delimiter ";" -Path E:\Tempfolder\testCSV.csv" -Encoding Unicode ######### Add to SPList ######## $spWeb = Get-SPWeb -identity $WebUrl  #  Get SPWeb $list = $spWeb.Lists[$Listname] # Get SPList for($i = 0; $i -le $DataSet.Count; $i++) { #Read current row $row = $DataSet[$i] $item = $list.Items.Add(); $item["SPColumn1"] = $row.'Column1' $item["SPColumn2"] = $row.'Column2' $item["SPColumn3"] = $row.'Column3' $item["SPColumn_n"] = $row.'Column_n' $item.Update() }

Post a Comment

1 Comments

  1. Extremely useful information which you have shared here. This is a great way to enhance knowledge for us, and also helpful for us. Thankful to you for sharing an article like this.
    Mexico Export Data

    ReplyDelete