- Official Post
You can import easily a CSV file in your SharePoint List. If you have a file with special characters like french ones (éàè) you should save your file as CSV UTF-8 format.
You have to first load a module in your PowerShell Session (which you open as admin as usual)
If you connect to your Sharepoint you can test it with (after Connect-PnPOnline)
PowerShell
Get-PnPlist
Example for Connect-PnPOnline
Connect-PnPOnline -Url "https://yourURL.tld" -Credentials (Get-Credential)
For the correct field name from sharepoint you have to edit the column and than look in the URL how it is written
PowerShell
https://xy.com/site01/_layouts/15/FldEdit.aspx?List=%7BDC358694-4BDB-4369-BA40-F8CB09535F10%7D&Field=Full_x0020_Name
In the URL you will find Field= at the end of it and what is written behind is the field name you have to take in the script (Here in the example: Full_x0020_Name)
Now you can execute the full script (see below)
Script:
PowerShell
$credentials = Get-Credential -Message "Please Enter SharePoint Online credentials"
$Site="https://xy.com/site01/"
$TestData = Import-CSV "C:\scripts\testutf8.csv"
Connect-PnPOnline -Url $Site -Credentials $credentials
foreach ($Record in $TestData){
Add-PnPListItem -List "Name of the list" -Values @{
"Title"= $Record.'Shortcut';
"Full_x0020_Name"= $Record.'Full Name';
}}
The Records are defined with SharePointColumnName = $Record.'ColumnNameInCSVFile'