0

Consider comparing objects in $refs and $difs:

Compare-Object -ReferenceObject $ref -DifferenceObject $dif -Property $property

What about if I want to compare $refs[i].Name + ' new' with $difs[i].Name? What kind of $property should I set?

kakakali
  • 159
  • 1
  • 11
  • [Compare-Object](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.2) as documented, for those switches, only accept: ```Compare-Object --- [-ReferenceObject] --- [-DifferenceObject] ```. Just capture what you want as an object to a new variable and pass that in. – postanote Nov 10 '22 at 05:07
  • @postanote Yeah, the script block works. – kakakali Nov 10 '22 at 06:20
  • @postanote To clarify, what I've done is in -Property value because I need to get the original objects when comparing calculated properties. – kakakali Nov 10 '22 at 06:27
  • Using this [`Join-Object script`](https://www.powershellgallery.com/packages/Join)/[`Join-Object Module`](https://www.powershellgallery.com/packages/JoinModule) (see also: [In Powershell, what's the best way to join two tables into one?](https://stackoverflow.com/a/45483110/1701026)): `$ref |Join $dif -on { $_.Name + ' new' } -eq Name` – iRon Nov 10 '22 at 12:49

0 Answers0