我有一个对象数组,并试图操纵它,并得到属性RptFile不存在的错误。我检查了拼写和所有内容,对于发生的事情感到困惑。找不到对象存在属性
代码给错误:
$AllContents | Where-Object {$_.RptFile -eq 'CB-Officer Trial New'}
AllContents | Get-Member returns:
TypeName: Selected.System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
RptFile NoteProperty System.String RptFile=ABL - Branch5206 Daily OD Report
TotalSeconds NoteProperty System.String TotalSeconds=25
所以物业确实存在。任何想法是怎么回事?如果我只输入$ AllContents,我也会得到一个带有属性的列表。
,给出了一个列表,其中当我输入$ AllContents时得到的结果。我正在尝试过滤。 – user1612851
使用where子句添加管道: –
无法在此对象上找到属性'RptFile'。确保它存在。 在线:1 char:37 + $ rptFile = $ AllContents |其中{$ _。 <<<< RptFile -eq'CB-Officer Trial New'} | Select -Expand RptFile + CategoryInfo:InvalidOperation:(。:OperatorToken)[],RuntimeException + FullyQualifiedErrorId:PropertyNotFoundStrict – user1612851