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()
}
Powershell Import Data from csv to sharepoint 2013 list with special characters
Tags
Import CSV
Powershell
About GowthamPower Platform and Copilot Studio architect sharing practical Microsoft engineering notes, implementation patterns, and lessons learned from real projects.
Subscribe to:
Post Comments (Atom)
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.
ReplyDeleteMexico Export Data