In this post we will discuss how we can add an item to a SharePoint 2016 list using PowerShell. For this example I have created a simple custom list which has fields like:
– Title (Single line of text)
– Email ID (Single line of text)
– Contact Number (Single line of text)
– Courses (Choice Column)
– UserComments (Multiline text)
And the list looks like below:
Also you can read:
– Deploy Administation approved InfoPath forms in SharePoint 2013
– Create user profile synchronization connection in SharePoint 2013
Below is the PowerShell command.
Here make sure you can use the internal column names while adding items to the list. You can follow below articles to get internal column names of a list.
– Get SharePoint List Field Intenal Name in SharePoint 2013
– Get internal name of a list field in SharePoint 2013
– Get internal names using client object model in SharePoint 2013
Just put the below code in PowerShell ISE and run the command.
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
$webURL = “http://mypc:29024/sites/SPTraining/”
$listName = “MyTrainingListFromDesigner”
$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]
$newItem = $list.Items.Add()
$newItem[“Title”] = “Bijay”
$newItem[“Email_x0020_ID”] = “email@example.com”
$newItem[“Contact_x0020_Number”] = “123455666”
$newItem[“Courses”] = $newItem.Fields[“Courses”].GetFieldValue(“SharePoint Developer”);
$newItem[“UserComments”] = “I am interested for sharepoint training. please contact me.”
Once you execute the PowerShell command, the item will be added to the list.
Download FREE SharePoint 2019 Installation PDF Guide
This FREE PDF contains, Steps by step guide to install SharePoint 2019 Preview, prerequisites, hardware and software new features. First impression to SharePoint Server 2019 new modern site, modern lists and modern document libraries.