I recently discovered that I can access a property for something that is not displayed when run through get-member.
Here is an example that I will demonstrate using custom psobject.
First I will create a hash table (which I will use later to create psobject):
$MyHashtable = @{'column1'="aaa"; 'column2'="bbb"; 'column3'="ccc" }
Now I create my psobject:
PS C:\> $MyNewObject = New-Object -TypeName PSObject -Property $MyHashtable
Now, if I run this new object via get-member, it shows:
PS C:\> $MyNewObject | Get-Member TypeName: 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() column1 NoteProperty System.String column1=aaa column2 NoteProperty System.String column2=bbb column3 NoteProperty System.String column3=ccc
So far, so good (although I suspect that the property called "PSObject" is not in the list above, which I am going to demonstrate now).
However, if I do now:
PS C:\> $MyNewObject.PSObject Members : {System.String column1=aaa, System.String column2=bbb, System.String column3=ccc, string ToString()...} Properties : {System.String column1=aaa, System.String column2=bbb, System.String column3=ccc} Methods : {string ToString(), bool Equals(System.Object obj), int GetHashCode(), type GetType()} ImmediateBaseObject : BaseObject : TypeNames : {System.Management.Automation.PSCustomObject, System.Object}
It worked! How is this possible since "PSObject" was not specified as a property when we passed the object through the Get-Member.
Hope someone can help.