How to Create a List Item with All Possible List Columns in SharePoint Online Using PowerShell Script
Kavali Rakesh (H1B holder with valid work Authorization)
Senior SharePoint Online Developer | Office 365 | Power Platform | PowerApps | Power Automate | PowerBI | Migration Expert | SPFX | React | Team Lead | Frontend Developer | ASP.NET MVC | .NET Core
This article will provide a step-by-step guide on how to create a list item in SharePoint Online with various types of columns, such as text box, choice, multiple choice, people picker, lookup, and more. The script will use PowerShell to connect to SharePoint Online and create a new list item with the specified column values. This article will also explain how to adjust the script to match the column names in your own SharePoint Online environment.
#PowerShellScript #SharePointOnline #ListColumns #ListItems #Office365 #Automation #Productivity #Microsoft #CloudComputing #Collaboration # Connect to SharePoint Online
Connect-SPOService -Url https://<your tenant>-admin.sharepoint.com
# Define the site URL and list name
$siteUrl = "https://<your site>/"
$listName = "<your list name>"
# Get the list
$list = Get-SPOList -WebUrl $siteUrl -Identity $listName
# Create a new list item
$newItem = $list.AddItem()
# Set column values
$newItem["Title"] = "<your title>"
$newItem["Description"] = "<your description>"
$newItem["ChoiceColumn"] = "Choice1"
$newItem["MultiChoiceColumn"] = "Choice1;Choice2;Choice3"
$newItem["SingleLineTextField"] = "<your text>"
$newItem["MultiLineTextField"] = "<your text>"
$newItem["HyperlinkColumn"] = "<your URL>, <your description>"
$newItem["CurrencyColumn"] = 100
$newItem["DateColumn"] = Get-Date
$newItem["DateTimeColumn"] = Get-Date
$newItem["BooleanColumn"] = $true
$newItem["PersonOrGroupColumn"] = "<user email address>"
$newItem["LookupColumn"] = $list.GetItemById(1)
# Save the new item
$newItem.Update()