cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

PS Command for import from Excel to SharePoint

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

12 REPLIES 12

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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.

Bild1.PNGBild2.PNGBild2.PNG

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'
}
}

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (31,398)