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
Please follow the steps:
1.In my test, the Demo.csv file has 100 rows of data.
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)
    };
}
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






