I have a custom powershell object created with a function:
$obj = myfunction -name "hello" -value 5
After it's created I want to change the value property however doing it (demonstrated below) doesn't work
$obj.value = 1
I've searched and can't seem to find anything - can anybody explain how I can accomplish this?
Here is my function that creates an returns the object
function myfunction
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
Param
(
[Parameter(Mandatory=$true,
Position=0)]
[String]
$name,
[Parameter(Mandatory=$true,
Position=1)]
[int]
$value,
)
Process
{
$myfunction = @{
name = $name
value = $value
}
write-output $myfunction
}
}