I have created a PsCustomObject, when the variable is called is ISE, it reads a table of the relevant data. However, if I try to compare the PsCustomObject with another object, the PsCustomObject doesn't read correctly. I'd like to tell the script if any of the lines in the existing CSV match the PSCustomObject do not export the data to the CSV, in other words skip duplicate rows in the CSV file. The CSV may or may not have multiple rows.
$fileInfo = @(
[pscustomobject]@{
user_id = $user
studio = $studio
function = $Task
end_time_local = $creationTime
asin = $ASIN
variant = $variant
process_class_id = $processClass
}
)
$currentData = Import-Csv "$scansFolder\$fileName.csv"
if($fileInfo -ne $currentData){
$fileInfo | Export-Csv "$scansFolder\$fileName.csv" -Append -NoTypeInformation -Force
}
Compare-Objectcmdlet.$fileInfovariable is an array. Do you need to support multiple custom objects to exclude from the CSV?$fileInfo.foreach($line in $currentData){ if($fileInfo -ne $currentData){ $fileInfo | Export-Csv "$scansFolder\$fileName.csv" -Append -NoTypeInformation -Force }}Any ideas on how to do that?Compare-Objectcmdlet to find out if ONE object is in a collection of similar objects. take a look at the-IncludeEqualparameter.