无法在存在的对象上找到属性

use*_*851 7 powershell powershell-2.0

我有一个对象数组,我试图操纵它,并得到一个错误,属性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   
Run Code Online (Sandbox Code Playgroud)

所以财产确实存在.知道发生了什么事吗?如果我只输入$ AllContents,我也会得到一个包含该属性的列表.

Dav*_*ant 1

$rptFile = $AllContents | Select -Expand RptFile | Where { $_ eq 'CB-Officer Trial New' } 
Run Code Online (Sandbox Code Playgroud)