I'm looking for some help with PnP PowerShell. I have a script which takes a CSV file and uploads each row as an item to SharePoint Online (see below). My question is, how do I get the script to skip items that already exist in the SharePoint Online list? Currently the script just uploads all rows within the CSV and creates some duplicates.
#Parameters
$SiteUrl = "{site}"
$ListName = "iPhone"
$CSVPath = "C:\Users\{user}\Documents\PowerShell\Upload SharePoint items from CSV\iphoneexport.csv"
#Get the CSV file contents
$CSVData = Import-CsV -Path $CSVPath
#Connect to site
Connect-PnPOnline $SiteUrl -Interactive
#Iterate through each Row in the CSV and import data to SharePoint Online List
ForEach ($Row in $CSVData)
{
Write-Host "Adding Item $($Row.'Asset Number')"
#Add List Items - Map with Internal Names of the Fields!
Add-PnPListItem -List $ListName -Values @{"Title" = $($Row.'Asset Number');
"User" = $($Row.User);
};
}
I'd be grateful for any advice anyone can give.
Many thanks,
Alex.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.