# Instead of using Compare-Object to compare two datasets, such as for strings or integeters, consider using HashSet instead.
$referenceIds = [System.Collections.Generic.List[string]]@()
$differenceIds = [System.Collections.Generic.List[string]]@()
$leftOnlyObjects = Compare-Object -ReferenceObject $referenceIds -DifferenceObject $differenceIds |
Where-Object { $_.SideIndicator -eq "<=" } | Select-Object -ExpandProperty InputObject
$referenceHash = New-Object 'System.Collections.Generic.HashSet[String]'
$referenceHash.UnionWith($referenceIds)
$differenceHash = New-Object 'System.Collections.Generic.HashSet[String]'
$differenceHash.UnionWith($differenceIds)
$leftOnlyHash = New-Object 'System.Collections.Generic.HashSet[String]'($referenceHash)
$leftOnlyHash.ExceptWith($differenceHash)
$leftOnlyObjects = $leftOnlyHash