PowerTip: Use PowerShell to Compare Two Objects
Summary: Use Windows PowerShell to compare two objects to view differences and similarities.
How can I compare two objects and see the values that differ and exist in both?
Charlotte Windows PowerShell User Group member Brian Wilhite says: There is a cmdlet that will make life easy for you. The cmdlet is Compare-Object, and it will compare two objects and detail the results. The IncludeEqual parameter will list the properties that exist in both objects.
$OneToFive = 1..5
$OneToTen = 1..10
Compare-Object -DifferenceObject $OneToFive -ReferenceObject $OneToTen –IncludeEqual