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.
Powershell

Avatar of undefined
Last Comment
aikimark

8/22/2022 - Mon
aikimark

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

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

ASKER

Yes.

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

just Taste, nothing else

aikimark

How is your $Fruits variable defined?

Pardon the pun, but I want to avoid an apples-to-oranges solution.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.