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:
PSComputerName | USERNAME | ID | STATE | IdleTime | LogonTime |
---|---|---|---|---|---|
Servername | User | 19 | Disc | 2:45 | 13.03.2024 18.00 |
Servername | User 2 | 20 | Active | 2:45 | 14.03.2024 11.00 |
-
How can I mark all of the results with the STATE “Disc” as a gray background (make a different style) and the results with the green background if the logonTime duration is -1 hour?
-
The table is now displayed in fullscreen mode. How do I arrange this in a small window? The table continued to display in fullscreen even after I put it in the UD-card.
Looking forward to the answers Thank you.
Product: PowerShell Universal
Version: 4.2.13