Working with arrays in Endpoints

Good evening all,

I have run into a slight issue with an array created within an endpoint.

$Cache:ArrayName = @()
$details = [PSCustomObject] #object has multiple items within it#
$Cache:ArrayName += $details

I then attempt to display the data within the custom object on a New-UDCard.

New-UDCard  -Title "Example Title" -Endpoint {

foreach ($item in $Cache:ArrayName){

       New-UDParagraph -Text "Here is the attempt to loop through the array" 

Am I approaching this topic correctly or have I missed this by a mile?

what is the issue?

please provice more info on the pscustomobject

Hi @K_Summers
Sadly, as the $Cache variable is not a fully functional variable you cannot do the whole “+=” append part of a hashtable.

Either try:
$details = #insert custom object stuff
$cache:array = $details

Or build a function to rebuild the cache variable based on existing content + the new variable.

Note: havent actually tested that part, but should work (judging by my brain, 1,5 cups of coffee down on a tuesday)

Happy hunting!