Advertisement
guyrleech

Compare 2 Powershell Objects

Sep 8th, 2022
1,789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## iterate over properties for one object to create an array of properties for Select-Object
  2.  
  3. $differentProperties = ForEach( $prop in $good.psobject.properties ) { if( $bad.psobject.properties[ $prop.name ] ) { if( $prop.value -ne $bad.psobject.properties[ $prop.name ].value ) { $($prop.name) } } else { $prop.name } }
  4.  
  5. $( $good ; $bad ) | select-Object -Property $differentProperties
  6.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement