I'm trying to use the PowerShell Add-Member cmd on all the items in an array and then access the member I added later but it doesn't show up.
You can see in the output of the below code that the NoteProperty appears to exist within the scope of the foreach statement but it doesn't exist on the same object outside of that scope.
Any way to get this script to show isPrime
on both calls to Get-Member?
$p = @(1)
$p[0] | %{ add-member -inputobject $_ -membertype noteproperty -name isPrime -value $true; $_ | gm }
$p[0] | gm
output
TypeName: System.Int32
Name MemberType
---- ----------
CompareTo Method
Equals Method
GetHashCode Method
GetType Method
GetTypeCode Method
ToString Method
isPrime NoteProperty
CompareTo Method
Equals Method
GetHashCode Method
GetType Method
GetTypeCode Method
ToString Method