0

I am reading data from CSV which is having 10000 items and creating on SharePoint list items. I want to put that in batch using pnp PowerShell. Some one suggest me batch functionality how to use?

1 Answer 1

1

Please follow the steps:

1.In my test, the Demo.csv file has 100 rows of data.

enter image description here

2.Please run the below PnP PowerShell script to import the first 20 rows of data into SharePoint list

#Parameters
$SiteUrl = "https://domain.sharepoint.com/sites/sitename"
$ListName = "listname"
$CSVPath = "C:\temp\Demo.csv"
 
#Import data rows 1~20
$CSVData = Import-CsV -Path $CSVPath | Select-Object -Skip 0 -First 20

#Connect to site
Connect-PnPOnline $SiteUrl -Credentials (Get-Credential)
 
#Iterate through each Row in the CSV and import data to SharePoint Online List
ForEach ($Row in $CSVData)
{
    Write-Host "Adding Contact $($Row.FirstName)"
     
    #Add List Items - Map with Internal Names of the Fields!
    Add-PnPListItem -List $ListName -Values @{"Title" = $($Row.Title);
                            "ColumnA" = $($Row.ColumnA);
                            "ColumnB"=$($Row.ColumnB)
    };
}

enter image description here

enter image description here

3.Modify the code in line 6 as follows, you can import the data in lines 21-40 into the list

#Import data rows 21~40
$CSVData = Import-CsV -Path $CSVPath | Select-Object -Skip 20 -First 20

enter image description here

enter image description here

1
  • Thank you@EchoDu_MSFT
    – Liz
    Feb 17, 2022 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.