我有一個對象數組,並試圖操縱它,並得到屬性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