Try to do something like this:
$session:mygridvar=@()
$myrow="" | select-object field0,field1,field2,field3,field4
$myrow.field0=“A”
$myrow.field1=“B”
$myrow.field2=“C”
$myrow.field3=“D”
$myrow.field4=“E”
$session:mygridvar+=$myrow
$myrow.field0=“1”
$myrow.field1=“2”
$myrow.field2=“3”
$myrow.field3=“4”
$myrow.field4=“5”
$session:mygridvar+=$myrow
New-UDGrid -ID ‘ABC’ -Title “ABC” -Headers @(“1”, “2”, “3”,“4”, “5”) -Properties @(“field0”, “field1”,“field2”,“field3”, “field4”) -Endpoint {
$session:mygridvar | Out-UDGridData
}
everything is working fine as Long as i do not use session context.
$mygridvar=@() -> works fine
$session:mygridvar=@() -> get error:
Exception calling “Invoke” with “0” argument(s): “Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named ‘op_Addition’.”
But I Need session context to work with $mygridvar in other places …
Can someone please help me?