PnP provisioning is a community-driven platform that enables fast development of components that define your application infrastructure & the content to some extent. We use CSOM and can work against both SharePoint Online and SharePoint On-Premises. Let’s see how to do the Create list Item using PNP.
Prerequisite
Before you begin utilizing PowerShell to oversee SharePoint Online, ensure that the SharePoint Online Management Shell is installed. You can install the SharePoint Online Management Shell by downloading and running the
SharePoint Online Management Shell. You only need to do this once for each computer from which you are running SharePoint Online PowerShell commands.
Connect to Site
Connect to SharePoint site using Connect-PnPOnline cmdlet. The required parameters are,
The following code snippet helps to connect SharePoint sites.
- $siteurl="https://<tenant-name>.sharepoint.com"
- Connect-PnPOnline -Url $siteurl
To Create a list Item,
The list item can be created by “Add-PnPListItem” cmdlet in a SharePoint site.
The required parameters are,
-List - The ID, Title, or Url of the list.
-Values - Use the internal names of the fields when specifying field names.
The following code snippet helps to create SharePoint List item
- Add-PnPListItem-List "HubflyTeam" -Values @{"Title"="Hubfly";"NameHF"="Ravishankar";"AgeHF"="21";"RoleHF"="Developer"}
Thus, you have learned how to create list items programmatically SharePoint site. PnP PowerShell is supported by SharePoint Online. The operations mentioned above, are tested on SharePoint Online environments. Feel free to fill up the comment box below, if you need any assistance.