In powershell i have two "tables" or lists, I am not sure about the right wording. One is obtained from a sharepoint list and the other from an sql table. Both lists have numbered elements which I can iterate through and each element has a bunch of named elements with a name and a value Fist question: what do you call this in powershell? (IN SQL I would simply call it table, in other programming languages probably something array of structs) Now what I want to do is to compare both lists based on two "columns" and find entries which are new or deleted in the second List. So what I can do is iterate through one List and compare each entry like this my code example. If both Lists are long, this takes really long and aditionally I have to do it a second time with both lists interchanged to find new AND deleted entries. I already tried to figure out if it can be done more efficient, probably with something like compare-object .... hope you guys have an idea!
ForEach ($Row in $Obj2)
{
$Cnt = ($Obj1 | Where-Object{$_["ID"] -eq $Row["P_ID"] -and $Row["ITEM"] -eq $_["part"]}).Count
if ($Cnt -ne 1)
{
write-host do something
}
}