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 Administration approved InfoPath forms 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 Internal Name in SharePoint 2013
– Get the 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.
Hope this will be helpful.
SharePoint Online FREE Training
JOIN a FREE SharePoint Video Course (3 Part Video Series)