We can check the item by CAML+ PNP PowerShell, if the Title in list already exists, it will be ignored, check as following:
$Username='julie@tenant.onmicrosoft.com'
$Password = 'Doh76594'
#region Credentials
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass)
#endregion Credentials
#connect to site
$consite=Connect-PnPOnline -Url 'https://tenant.sharepoint.com/sites/Team1' -Credentials $PSCredentials
$listName = "list1022"
$FilePath= "C:\Temp\Test1028.csv"
$CSVData = Import-CsV -Path $FilePath
Import-Csv -Path $FilePath|%{
$checkitem = $null
$tarTitle= $_."Asset Number"
$tarUser = $_.User
$caml=@"
<View>
<Query>
<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>$tarTitle</Value></Eq></Where>
</Query>
</View>
"@
$checkitem= Get-PnPListItem -List $listName -Query $caml
if($checkitem){
Write-Host "this item exists:" $($tarTitle)
}else{
Write-Host "this item does not exist:" $($tarTitle)
Add-PnPListItem -List $ListName -Values @{"Title" = $($tarTitle);
"Active" = $($tarUser );}
}
}
Before:
After:
Simialr issue for your reference:
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.