IIRC is really connected with PSObject wrappers, which is a key element of the extended type system in PowerShell 2.0. When you do this:
$x = new-object psobject $x | add-member noteproperty test 'xtest' $x.test
This works because the object is already a PSOject, so the Add-Member can add a new NoteProperty directly to PSObject, for example:
$y = @{} $y | add-member noteproperty test 'ytest' $y.test
This does not work because $y not initially wrapped, so when you execute the Add-Member, it creates a new object that wraps the original hash table. You can see this using Get-Member, for example:
$y | Get-Member
You will not see your test property. To make this work in v2, you must do this:
$y = $y | add-member noteproperty test ytest -passthru $y.test ytest
FYI, this changes in V3, since it is based on DLR, it directly modifies the object without creating a new wrapper object, for example:
# PowerShell V3 only 16
source share