开发者

Question regarding powershell Compare-Object - issue capturing output to variable

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜