I think this is going to come across as a really basic question, but ive looked at multiple examples and the docs and im unsure whats going on.
I need to understand better exactly what it is that we’re supplying the chart components with. is it an object? im assuming its more a collection of objects (so in powershell terms an array of custom objects).
ive managed to draw what i wanted with an array of objects. just wondering if im on the right lines.
thanks
Yeah, you’re on the right track, pipe a collection into Out-UDTableData and specify the properties for each object in the collection you want.
Example:
Assume that $arr is a collection of objects that all have a Property1 and Property2 property
New-UDTable -Headers @("Property1Header", "Property2Header") -endpoint {
$arr = [some method of populating your array here]
$arr | Out-UDTableData -property @("Property1", "Property2")
}
To give you a real-world example, this is what I use to populate our call center dashboard:
New-UDTable -headers @("Name","Status","Duration","Calls Answered","Average") -BackgroundColor "#121f1f" -FontColor 'orange' -endpoint {
$date = get-date
$filePrefix = "$(($date).month)"+"."+"$(($date).day)"+"."+"$(($date).year)" # month.day.year, ex: 2.17.2019
$src = gc P:\Reporting\IPlex\CallStats\$filePrefix-stats.JSON | convertFrom-JSON
$src |sort callsAnswered -descending | foreach-object{
if($_.status -eq "Available")
{
[PSCustomObject]@{
Name = $_.user
Status = New-UDElement -Tag 'div' -Attributes @{style = @{color = $_.color}} -content {$_.status}
Duration = $_.statusTime
AverageTalk = $_.averageTalk
TotalTalk = $_.totalTalk
CallsAnswered = $_.callsAnswered
E1sAnswered = $_.e1CallsAnswered
}
}
else
{
[PSCustomObject]@{
Name = $_.user
Status = New-UDElement -Tag 'div' -Attributes @{style = @{color = $_.color}} -content {"$($_.status) - $($_.callerNamed)"}
Duration = $_.statusTime
AverageTalk = $_.averageTalk
TotalTalk = $_.totalTalk
CallsAnswered = $_.callsAnswered
E1sAnswered = $_.e1CallsAnswered
}
}
} | out-udtabledata -property @("Name","Status","Duration","CallsAnswered","AverageTalk")
} -autorefresh -refreshinterval 5
Note:
$src is a collection of objects that have the following properties:
Name,Status,Duration,AverageTalk,TotalTalk,CallsAnswered,E1CallsAnswered
That all produces this table:
I’ve got examples of graphs and such, let me know if I can help in any other way
1 Like
delayed response, but thanks for the reply. good example, i got what i needed from it. thanks.
1 Like