7

オブジェクトの配列があり、それを操作しようとすると、プロパティ 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 と入力すると、プロパティのリストも表示されます。

4

4 に答える 4

3

最初に試す

$AllContents[0].RptFile = '<value>'

このようなものが役に立たない場合:

[Your.Interface.Implemented.Explicitly].GetProperty("RptFile").SetValue($AllContents[0], '<value>',$null)
于 2014-02-04T13:41:19.613 に答える