Hello everybody,
I have a list in SharePoint with 10 columns and I always get excel files sent with the exact same 10 columns. Now I would like to transfer the Excel content to the SharePoint list. Is there a Powershell command that makes an import possible?
P.S. There is an export button at excel, but he keeps putting me on a new list in SharePoint. I would like to use the same list.
Best regards Christian
I have the solution. There was a delimiter missing. The CSV had to be separated per column entry.
Here is the code:
$CustomerData = Import-CSV “D:\Test.csv” -Delimiter ";"
PS C:\WINDOWS\system32> foreach ($Record in $CustomerData){
Add-PnPListItem -List "TestCSV2" -Values @{
"Title"= $Record.'Personalnummer';
"Personalnummer"= $Record.'Personalnummer';
"Vorname"= $Record.'Vorname'
}
}
Hi v-xida-msft,
Thank you for your answer.
If I add the "title" comes following (see picture). When I name the title as german name "Titel", he says he does not know the column.



Hi @Christian866 ,
Have you specified the Title column within the Foreach function in your PowerShell window?
Please consider modify your Foreach function as below:
foreach ($Record in $CustomerData){ Add-PnPListItem -List "TestCSV" -Values @{ "Title"= $Record.'Personalnummer'; "Personalnummer"= $Record.'Personalnummer'; "Vorname"= $Record.'Vorname' }
}
please consider take a try with above PowerShell cmdlet, then check if the issue is solved.
Best regards,
Here is the new list ... unfortunately empty again with the same foreach loop.
You can now see the contents of the csv file as well.


Hi @Christian866 ,
Yeah, you are right.
Please take a try with your new created SP List, try the Foreach function in your PowerShell window again, check if the issue is fixed.
Best regards,
I have now deleted the list and created one again with the same name.
The title I left, only the first name and staff number I have created. Is this correct?

Maybe you wanna see my csv file?
Hi @Christian866 ,
Do you rename the Title column into "Personalnummber" column in your TestCSV SP List?
Please do not rename the Title column within your TestCSV SP List when you import CSV Data from your CSV file into your SP list using PowerShell cmdlet.
On your side, please consider change your "Personalnummber" column back to Title column in your TestCSV SP List, or re-create a new SP List, then try the Foreach function again, check if the issue is solved.
Best regards,
I have now managed to import the data, but only empty lines in the Sharepoint list (see the gray lines in the picture). How can something like that happen?


Hi @Christian866 ,
When you execute the Foreach action within your PowerShell window, you need to specify the List Name you want to import your CSV data to using following cmdlet:
Add-PnPListItem -List "Customer Database" -Values @{...}
In addition, for your second question, the answer is YES. You could have multiple lists on your SP Site.
Best regards,
Hello thank you for the quick feedback.
I'm just trying to go through the tutorial (https://practical365.com/sharepoint-online/csv-file-to-sharepoint/).
The First steps was fine.
i Connect to the SharePoint site and i import my csv to view all rows in Powershell. it works
I do not understand how he knows which list he should take on the URL?
I can have multiple lists on the SharePoint site?
Best regards Christian
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473