
Yes, you can create SharePoint list items via PowerShell without installing any additional modules like the SharePoint PnP PowerShell module.
Using CSOM via PowerShell, which allows you to interact with SharePoint without requiring any additional modules. The key is to use the SharePoint CSOM libraries, which are already available.
Here are steps to create SharePoint list items by using CSOM.
1.Download the SharePoint Online CSOM assemblies (DLLs) if they’re not already installed on your machine. You can get them from: SharePoint Online Client Components SDK
2.Example script that add an item to a SharePoint list using CSOM in PowerShell.
# Define variables
$siteUrl = "https://tenant.sharepoint.com/sites/site"
$listName = "ListName"
$userName = "******@yourdomain.com"
$password = "password"
# Path to SharePoint CSOM Assemblies
$csomPath = "C:\Path\To\Microsoft.SharePoint.Client.dll"
$csomClientRuntimePath = "C:\Path\To\Microsoft.SharePoint.Client.Runtime.dll"
# Load the necessary assemblies
Add-Type -Path $csomPath
Add-Type -Path $csomClientRuntimePath
# Create a secure password
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
# Set up credentials
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $securePassword)
# Connect to SharePoint Site
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$context.Credentials = $credentials
# Get the list by name
$list = $context.Web.Lists.GetByTitle($listName)
# Create a new list item
$newItem = $list.AddItem([Microsoft.SharePoint.Client.ListItemCreationInformation]::new())
# Set values for the columns (assuming your columns are "Title", "Column1", "Column2", and "Column3")
$newItem["Title"] = "Sample Title"
$newItem["Column1"] = "Value1"
$newItem["Column2"] = "Value2"
$newItem["Column3"] = "Value3"
# Update the list item
$newItem.Update()
# Execute the request to SharePoint
$context.ExecuteQuery()
Write-Host "Item added successfully!"
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.