Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell: add noteproperty to customobject

Hi,

I have a Powershell object  Selected.System.Management.Automation.PSCustomObject
to which I would like to add a noteproperty so I can populate it with a foreach

F.e. customobject is fruits
it has noteproperties colour,weight

In another script I d like to add taste noteproperty

How can I do this?

Tried
 $Fruits | Add-Member -MemberType NoteProperty -Name Taste -Value VeryGood -Force but then it adds everywhere test wheras I just need the extra Taste.

Please advise
J.
Avatar of aikimark
aikimark
Flag of United States of America image

Do you want to add the taste to every item in $Fruits?

Is there a difference between "Taste" and "extra Taste"?
Avatar of janhoedt
janhoedt

ASKER

Yes.

"wheras I just need the (extra) Taste."

just Taste, nothing else

How is your $Fruits variable defined?

Pardon the pun, but I want to avoid an apples-to-oranges solution.
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial