I am trying to st开发者_开发问答ore the results of a Compare-Object for later use.
When i store it in a variable, it comes up blank.
I reviewed the MSDN article on Compare-Object and it states no output is generated.
Any ideas on how to do this?
You can store the results of a comparsion like this:
$result = Compare-Object $object1 $object2
If you aren't getting anything put into $result, then the two objects are identical.
You can do:
$result = Compare-Object $a $b
$result will be empty when there is no difference. ( for example $result = Compare-Object $a $a
) . You can do something like if($result)
to see if there is a difference and proceed accordingly.
精彩评论