This code retrieves all of the users that are currently active from list of servers (using API) and displays them in the table.
Here is the code:
New-UDApp -Title 'TEST' -Content {
New-UDDynamic -Id 'tabel' -AutoRefresh -AutoRefreshInterval 5 -Content {
$data = Invoke-RestMethod -Uri http://xxx/Users -Method GET
$Columns = @(
New-UDTableColumn -Property PSComputerName -Title PSComputerName -IncludeInSearch -DefaultSortColumn
New-UDTableColumn -Property USERNAME -Title USERNAME -IncludeInSearch -DefaultSortColumn
New-UDTableColumn -Property ID -Title ID
New-UDTableColumn -Property STATE -Title STATE
New-UDTableColumn -Property IdleTime -Title IdleTime
New-UDTableColumn -Property LogonTime -Title LogonTime
)
New-UDTable -Id "tabel" -Title "Active users" -Columns $Columns -data $data -Size small -ShowSearch
}
}
Sample of output data:
Looking forward to the answers Thank you.
Product: PowerShell Universal Version: 4.2.13
Recommended Answer
my goto for organising stuff is Grids and columns
New-UDGrid -Container -Content {
New-UDRow -Columns {
New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
New-UDPaper -Content { "1" } -Elevation 2
}
New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
New-UDPaper -Content { "2" } -Elevation 2
}
}
}
Grid | v4 | PowerShell Universal
The screen is divided into 12 chunks. so it can fit 2 columns of size 6 fx
ExtraLargeSize, LargeSize, MediumSize, SmallSize and ExtraSmallSize is based on the current display area width. A typical PC widescreen would be ExtraLargeSize and as you make the browser window smaller it will shift to the next lower size.
my goto for organising stuff is Grids and columns
New-UDGrid -Container -Content {
New-UDRow -Columns {
New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
New-UDPaper -Content { "1" } -Elevation 2
}
New-UDColumn -ExtraLargeSize 6 -LargeSize 6 -MediumSize 6 -SmallSize 12 -ExtraSmallSize 12 -Content {
New-UDPaper -Content { "2" } -Elevation 2
}
}
}
Grid | v4 | PowerShell Universal
The screen is divided into 12 chunks. so it can fit 2 columns of size 6 fx
ExtraLargeSize, LargeSize, MediumSize, SmallSize and ExtraSmallSize is based on the current display area width. A typical PC widescreen would be ExtraLargeSize and as you make the browser window smaller it will shift to the next lower size.
Yes, this will organize better. Thank you PorreKaj
Any tips on question 1 ?
Solution for the QA 1
New-UDTableColumn -Property STATE -Title STATE -OnRender {
if ($EventData.STATE -eq 'DISC') {
New-UDParagraph -Text $EventData.STATE -Color 'red'
} else {
$EventData.STATE
}
}