【发布时间】:2017-06-28 07:15:49
【问题描述】:
示例代码:
$hosts = Get-View -ViewType hostsystem -Property name,network
$clusters = Get-View -ViewType clustercomputeresource -Property name,network,host
$hosts | Add-Member -MemberType AliasProperty -Name TEST -value MoRef
$clusters | Add-Member -MemberType AliasProperty -Name TEST -Value Host
我想在解析数据时加快我的脚本速度并想使用Compare-Object。
但是代码
Compare-Object $hosts $clusters[0] -Property TEST -IncludeEqual -ExcludeDifferent -PassThru
没有输出。
代码
Compare-Object $hosts.test $clusters[0].test -IncludeEqual -ExcludeDifferent -Pass -PassThru
给我完全匹配,但不通过对象。
很遗憾,我无法确定原因。
【问题讨论】:
-
您的最后一个代码 sn-p 中有一个虚假的
-Pass。除此之外,这两个Compare-Object语句对我来说都很好。能否提供样本数据(CSV 格式)?
标签: powershell powershell-4.0 powercli