我有两个数组,我试图使用compare-object比较它们。
这里的目标是获得不共同的项目。我将数据收集到两个数组$result1
和$result2
$result1
customersourceid
----------------
126025db-fefa-e511-9448-00155d9697e4
16ace738-fafa-e511-9448-00155d9697e4
18adb12c-9800-e611-9448-00155d9697e4
1ffc4181-01fb-e511-9448-00155d9697e4
20c8e80f-3efb-e511-9448-00155d9697e4
22f333a5-d0fc-e511-9448-00155d9697e4
23fe0537-90fd-e511-9421-00155da64f13
33cf599d-79fd-e511-9421-00155da64f13
3804aee1-b8ff-e511-9421-00155da64f13
3d241b9d-7af6-e511-9421-00155da64f13
463c6b7c-cfea-e511-9447-00155d9697e3
463c6b7c-cfea-e511-9447-00155d9697e3
496794e6-4f01-e611-9421-00155da64f13
5d06f8b0-0cfc-e511-9421-00155da64f13
5dac4791-a400-e611-9448-00155d9697e4
645f4358-f4ff-e511-9448-00155d9697e4
6adb2433-0bfc-e511-9421-00155da64f13
948db8b1-7afd-e511-9421-00155da64f13
9f221d59-13fb-e511-9448-00155d9697e4
9f3b7de7-c7fc-e511-9448-00155d9697e4
a0a1b520-bbff-e511-9448-00155d9697e4
a5400d23-cdb8-e511-9446-002dd817030c
ab25269d-e5f5-e511-9448-00155d9697e4
d918513c-48fa-e511-9421-00155da64f13
e04e7304-f200-e611-9421-00155da64f13
f200813b-c8fd-e511-9421-00155da64f13
fecf2b1c-abfd-e511-9421-00155da64f13
$result2
customersourceid
----------------
126025db-fefa-e511-9448-00155d9697e4
16ace738-fafa-e511-9448-00155d9697e4
18adb12c-9800-e611-9448-00155d9697e4
1ffc4181-01fb-e511-9448-00155d9697e4
20c8e80f-3efb-e511-9448-00155d9697e4
22f333a5-d0fc-e511-9448-00155d9697e4
23fe0537-90fd-e511-9421-00155da64f13
33cf599d-79fd-e511-9421-00155da64f13
3804aee1-b8ff-e511-9421-00155da64f13
3d241b9d-7af6-e511-9421-00155da64f13
463c6b7c-cfea-e511-9447-00155d9697e3
463c6b7c-cfea-e511-9447-00155d9697e3
496794e6-4f01-e611-9421-00155da64f13
5d06f8b0-0cfc-e511-9421-00155da64f13
5dac4791-a400-e611-9448-00155d9697e4
645f4358-f4ff-e511-9448-00155d9697e4
6adb2433-0bfc-e511-9421-00155da64f13
948db8b1-7afd-e511-9421-00155da64f13
9f221d59-13fb-e511-9448-00155d9697e4
9f3b7de7-c7fc-e511-9448-00155d9697e4
a0a1b520-bbff-e511-9448-00155d9697e4
a5400d23-cdb8-e511-9446-002dd817030c
ab25269d-e5f5-e511-9448-00155d9697e4
d918513c-48fa-e511-9421-00155da64f13
e04e7304-f200-e611-9421-00155da64f13
f200813b-c8fd-e511-9421-00155da64f13
fecf2b1c-abfd-e511-9421-00155da64f13
以下是代码:
Compare-Object $result1.customersourceid $result2.customersourceid
我既没有收到错误消息,也没有得到结果。有人可以帮忙吗?
答案 0 :(得分:2)
列表相同,这就是你没有得到结果的原因。默认情况下,compare-object
仅显示差异。
如果您还想查看等号,请将参数-IncludeEqual
添加到您的命令中:
Compare-Object $result1.customersourceid $result2.customersourceid -IncludeEqual