I am looking for missing events between two arrays: $tc_records
& $RelationshipEvents_array
. Both arrays should have the same two entries.
An entry for A->B and reverse B->A. When I'm evaluating RelationshipEvents with -and statement, does one (same) event gets evaluated, or each side of the -and loads the array and evaluates is independently.
foreach ($record in $tc_records) {
# is this using the same RelationshipEvent for both comparisons or two different comparisons?
if($RelationshipEvents_array.entity1Id -eq $record.entity1Id -and $RelationshipEvents_array.entity2Id -eq $record.entity2Id){
$re_tc_matched_record.Add($record)
} else {
$re_tc_not_matched_record.Add($record)
}
}
in case this makes any difference:
Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Darwin 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
It looks like your two arrays hold similar objects with various properties. When you perform this:
You're actually comparing an array holding all the
entity1Id
properties (calculated by getting the property of that name from each of the objects in the$RelationshipEvents_array
array) with theentity1Id
property of the current$record
object.This is unlikely to ever evaluate to true given the different object types unless I've misunderstood your question.
What I would normally do when making a comparison like this is something like the following to get a match:
However, since you're trying to match two properties the simplest way might be to:
Iterate through the array for each record you check in a second foreach loop