New-UDTable within New-UDCollapsibleItem not seeing variable

Hi

I’m trying to generate a list of collapsible items containing a UDTable of details from pscustomobject. I thought I had it working as when launching the dashboard locally from a PS session it works as expected, unfortunately when launching it as an Azure Webapp I can an error in each UDTable saying " An item with the same key has already been added."

This is my code:
New-UDHeading -Text ‘Provisioned Users’ -Size 5 -Color ‘#FFFFFF
New-UDCollapsible -Items {
$provisionedusers = Invoke-RestMethod -Method Get -Uri $UserAccountReportTableSASuri
-Headers $AzTableSASHeaders
$provisionedusers.value | Sort-Object Timestamp -Descending | Select-Object -First 100 |
ForEach-Object {
$dt = $PSItem.Timestamp | Get-Date -Format “dd/MM/yyyy HH:mm”
$ItemTitle = ‘{0} | {1} | {2}’ -f $dt, $PSItem.EmployeeId, $PSItem.cn
$UserDetails = $PSItem
New-UDCollapsibleItem -Title $ItemTitle -Icon user -Content {
New-UDTable -Title “User Details” -Headers @(" ", " ") -Endpoint {
$ItemDetails = @{}
$ArgumentList[0].PSObject.Properties | ForEach-Object {
$ItemDetails.Add($PSItem.Name, $PSItem.Value)
}
$ItemDetails.GetEnumerator() | Out-UDTableData -Property @(“Name”, “Value”)
} -ArgumentList $UserDetails
}
}
}

This is the error in Azure:

Any advice on what could be happening here would be much appreciated!

Many Thanks!

1 Like

This is it working locally:

Ah, I resolved it by simplifying the code and piping the table argument straight to out-udtabledata:

$ArgumentList[0].PSObject.Properties.GetEnumerator() | Out-UDTableData -Property @("Name", 
"Value")