kreef
January 26, 2020, 12:48pm
1
I can’t seem to make the generated URLs in my table clickable. The Data is coming from SQL, if that matters.
$MyPage = New-UDPage -Name "My Page" -Icon fire_extinguisher -Content {
New-UDRow -Columns {
New-UDColumn -Size 12 -Content { }
New-UDColumn -Size 12 -Content {
New-UDTable -Title "Error Details" -Header @("ID", "URL", "Time Start", "Time End", "Issue") -Endpoint {
$cache:List | Out-UDTableData -Property @("id", "url", "start", "end", "issue")
} -RefreshInterval 10 -AutoRefresh
}
}
}
I found this link Hyperlinks in UDTables
But I can’t figure out how to translate this:
New-UDTable -Title "Server Information" -Headers @("Severity", "Name",'Affected Hosts') -Endpoint {
1..10 | foreach {
[pscustomobject]@{
Severity = 'CRITICAL'
Name = New-UDLink -Text 'KB123456' -Url "localhost\kb123456"
'Affected Hosts' = '123'
}
}| Out-UDTableData -Property @("Severity", "Name",'Affected Hosts')
}
I’m pretty clueless at how this is supposed to work unfortunately
Hey @kreef not something I have used myself yet, there used to be an example on poshtools I believe…there is info here:- Hyperlinks in UDTables
But from how I see if you need to foreach and put it into a PSCUSTOMOBJECT hashtable and specify the links using new-udlink
kreef
January 26, 2020, 6:08pm
3
Thanks again for the help @psDevUK
I tried a few variations of the example with a foreach , but I wasn’t sure if the pscustomobject applied to the SQL output in my variable, if that makes sense? But I suppose it’s just a string so it doesn’t matter where it comes from. When I do a foreach it’s normally like:
Foreach($url in $cache:list.url){
[pscustomobject]@{
Id= ‘*’
URL = New-UDLink -Text ‘$url’ -Url “$url”
}
}
But I will try playing with it some more and post my results if I manage to come right.
kreef
January 26, 2020, 9:48pm
4
Thanks @psDevUK ! I have made it work. Here is my code:
New-UDRow -Columns {
New-UDColumn -Size 12 -Content { }
New-UDColumn -Size 12 -Content {
New-UDTable -Title "Error Details" -Header @("ID", "URL", "Time Start", "Time End", "Issue") -Endpoint {
ForEach($cache:L in $cache:List) {
[PSCustomObject]@{
id = $cache:L.id
url = New-UDLink -Text $cache:L.url -Url $cache:L.url -OpenInNewWindow
issue_start = $cache:L.issue_start
issue_end = $cache:L.issue_end
issue = $cache:L.issue
} | Out-UDTableData -Property @("id", "url", "issue_start", "issue_end", "issue")
}
} -RefreshInterval 10 -AutoRefresh
}
}
}
Works perfectly, thanks for your help once again
1 Like
it’s highly unneeded to cache the foreach object do do this:
New-UDRow -Columns {
New-UDColumn -Size 12 -Content { }
New-UDColumn -Size 12 -Content {
New-UDTable -Title “Error Details” -Header @(“ID”, “URL”, “Time Start”, “Time End”, “Issue”) -Endpoint {
ForEach($item in $cache:List) {
[PSCustomObject]@{
id = $item.id
url = New-UDLink -Text $item.url -Url $item.url -OpenInNewWindow
issue_start = $item.issue_start
issue_end = $item.issue_end
issue = $item.issue
} | Out-UDTableData -Property @(“id”, “url”, “issue_start”, “issue_end”, “issue”)
}
} -RefreshInterval 10 -AutoRefresh
}
}
}