Introduction
Sometimes we need to create multiple list items at a time in SharePoint list due to a requirement - it could be while architecting the SharePoint application or doing SharePoint application testing. So when it comes to adding thousands of records in a list - it is not possible to add those records manually. Hence, the below script will be very helpful while handling this kind of requirement.
How to execute the above script?
Place the below two DLLs in your script directory "Dependency Files" folder as like below:
Change the value of the variable in the variables section like below:
- #variables region.
- $siteURL="https://globalsharepoint.sharepoint.com/sites/TestSite/" #Your Site URL
- $spUserName="YourUserName@<yourtenantname>.com"
- $password = "YourPassword"
- $spListName="Your List Name"
- $numberOfItemsToCreate="Number of times you want to create(Number like - 1000,2000,3000 etc)"
- #variables region end.
Execute the above script like below:
After execution - output:
We can see that n($numberOfItemsToCreate) number items are added to the SharePoint list automatically.
Summary
Hence, we have learned here how to create multiples items in SharePoint online in a batch using CSOM PowerShell.