In the realm of automation, PowerShell stands as a powerful scripting language that empowers administrators and developers to automate repetitive tasks efficiently. SharePoint, on the other hand, is a widely used collaboration platform for document management and content sharing. Combining the capabilities of PowerShell with SharePoint opens a plethora of possibilities, including the seamless synchronization of data from CSV files to SharePoint lists. In this blog post, I am sharing a sample script solution that you can utilize to sync CSV or excel to SharePoint list.
- Create a SharePoint List with same columns as in the CSV file to make it simple.
Prerequisites for this Solution:
https://www.powershellgallery.com/packages/PnP.PowerShell
Download the script from Git or PowerShell gallery from below links:
Git:
https://github.com/VikasSukhija/Downloads
SyncCSV2SpoList.ps1
PowerShell Gallery:
https://www.powershellgallery.com/packages/SyncCSV2SpoList
Install-Script -Name SyncCSV2SpoList
Update the below section of the script with your own parameters:

If CSV and SharePoint list columns are not same, then you can utilize Select-Object while importing CSV file to make it same programmatically inside the memory. Update the Script #######get list Items Section######## as per your list columns ans fetch that in a collection as shown in the sample.
Script utilizes compare-object to find addition and removal of items requirement for SharePoint List.
$addition
à items will be added to SharePoint List
$removal
à items will be removed from SharePoint list.
As all my scripts, this script also has a check on threshold that is count of changes to avoid unwanted addition or removal.

Script will auto generate encrypted password first time it is run and save it in the same folder as shown in below screenshot.

On first run you can modify the count of changes based on what you are expecting and make it a large number like 5000 etc., on recurring runs or scheduled runs just make it a smaller number like 50 that you expect as a daily change.
I hope you can utilize this solution in plenty of ways for your different automation needs.
Thanks for reading and downloading…
Tech Wizard