Script to add Multipile items at a time to SHarePoint list

sns 9,231 Reputation points
2022-02-13T14:11:35.16+00:00

I want to add multiple values at a time to list columns , please help me with script. PFA, I got excel sheet as per attached.
173800-listitemadding.png

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,276 questions
0 comments No comments
{count} votes

Accepted answer
  1. JoyZ 18,056 Reputation points
    2022-02-14T05:02:21.403+00:00

    @sns ,

    Create a csv file as shown below:

    173860-image.png

    Then run following pnp powershell to upload items from csv file to SharePoint list:

    $SiteUrl = "https://tenant.sharepoint.com/sites/Team1"  
      
    $ListName = "Test214"  
      
    $CSVPath = "C:\Temp\Test214.csv"  
      
    $CSVData = Import-CsV -Path $CSVPath  
      
    Connect-PnPOnline $SiteUrl -Interactive  
      
    ForEach ($Row in $CSVData)  
    {  
      
     Write-Host "Adding Item $($Row.'Title')"    
     #Add List Items - Map with Internal Names of the Fields!  
     Add-PnPListItem -List $ListName -Values @{"Title" = $($Row.'Title');  
                             "Column1" = $($Row.Column1);"Column2"= $($Row.Column2);  
     };  
      
    }  
    

    Result for your reference:

    173981-image.png

    173982-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful