Updating Sharepoint list with daily data
I have a CSV file that gets updated daily with three fields: a username, an email address, and a number.
The number changes every day.
Right now I've got a powershell script using to go through each row of the csv file and add it to the sharepoint list.
The problem is that I can't figure out how to get it to only create a new line if the username doesn't already exist, and to only update the number if it does. Right now my work around is using Remove-PNPListItems to wipe the data from the list before readding it, but that seems...not good.
I'm sure there's a way, but I'm a powershell noob. I appreciate any help people can offer!
Here is the code in question...
Import-Csv -Path $FilePath|%{
$tarTitle= $_."Title"
$tarEmail=$_."EmailAddress"
$tarDays=$_."Days"
foreach ($row in $FilePath)
{
add-PnPListItem -List $ListName -Values @{"Title" = $($tarTitle);"EmailAddress" = $($tarEmail);"Days" = $($tarDays);}
}