Reputation: 21
I am trying to compare two folders in powershell and have the answer be either true or false. Is there anyway to make this happen? Right now I have:
Compare-Object -referenceobject $d1 -differenceobject $d2 -includeequal
But this shows me for every item.
My end game is to have one of the folder names change if they are equal (True) (to mark one OLD).
Upvotes: 1
Views: 343
Reputation: 126722
You can negate the result and get a Boolean value. True if the objects are equal and False if they are not:
PS> $isEqual = compare (1..3) (1..3)
PS> !$isEqual # change one of the folder names
True
PS> $isEqual = compare (1..3) (2..3)
PS> !$isEqual
False
Upvotes: 3