Powershell 数组中包含比较无效

Powershell 数组中包含比较无效,powershell,Powershell,我有这个数组 $jobStatusResults.GetType(); IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array 包含 $jobStatusResults Value ----- Succeeded Succeeded Succeeded Succeeded Failed Succe

我有这个数组

$jobStatusResults.GetType();

IsPublic IsSerial Name      BaseType
-------- -------- ----      --------
True     True     Object[]  System.Array
包含

$jobStatusResults

Value    
-----    
Succeeded
Succeeded
Succeeded
Succeeded
Failed   
Succeeded
但我的比较声明不起作用

($jobStatusResults.Contains('Failed'))
False

有什么想法吗?

您正在访问一个自定义对象数组,而不是一个值数组。您需要首先访问Value属性

$JobStatusResults.Value -contains 'Failed'

您正在访问自定义对象数组,而不是值数组。您需要先访问
属性<代码>$jobstatusresults.value-包含“失败”太棒了,解决了它!你能把它作为一个答复,这样我就可以把它标记为已解决?它已被张贴。谢谢