Issue with Further Processing of Invoke PSU Script

Issue with Further Processing of Invoke PSU Script

avatar
Product: PowerShell Universal
Version: 5.5.1


Hello everyone, I’m currently stuck on a problem that I’d like to briefly describe.

I have created an app using PSU. From this app, I want to trigger a script and store the result in a variable for further processing.

The execution works, and I can display all values using Show-UDToast, for example $($data.path). However, I now want to create a table using these values along with additional details such as path, identity, and access.

Unfortunately, the data is not being processed correctly, and the result is 0.

avatar
(anonymous user)

Recommended Answer

@AnonymousUser After several attempts, I have now arrived at the result. I had to capture the $result from the invoke-psuscript with a $Session:data so that I could process it further. Sometimes it can be so simple when you use the right values

All Comments (3)

avatar

@AnonymousUser Here’s an example of a card I have on an app that gets a list of apps, based on some criteria, and displays them in a table. It’s the closest I currently have to what you are attempting. I grab the data in a function, assign it to a variable, pass that variable to the table’s -Data parameter then use $EventData.xxx to create a clickable link (or you can do other things in the table with $EventData. Hope it helps.

App code:

$appsHeader = New-UDCardHeader -Title 'Apps' -SubHeader 'List of apps to accomplish tasks' -Sx @{ backgroundColor = "#1976d2"; color = "white" }
        $appsBody = New-UDCardBody -Content {
            New-UDDynamic -Id "appTable" -Content {
                $apps = Get-Apps
                New-UDTable -Id "appTable" -Data $apps -Columns @(
                    New-UDTableColumn -Property "Name" -Render {
                        New-UDLink -Text $EventData.Name -Url $EventData.BaseUrl -OpenInNewWindow
                    }
                    New-UDTableColumn -Property "Description"
                ) -ShowPagination -Dense
            }
        }
        New-UDCard -Header $appsHeader -Body $appsBody


Module code:

function Get-Apps {
    $apps = Get-PSUApp -TrustCertificate | ForEach-Object {
        if ($_.BaseUrl -ne "/apps/docs" -and $_.Tag -ne "Test") {
            [PSCustomObject]@{
                Name    = $_.Name
                BaseURL = $_.BaseUrl
                Description = $_.Description
            }
        }
    }
    
    return $apps
}


avatar

@AnonymousUser thx for the fast reply. i ll take a look later

avatar

@AnonymousUser After several attempts, I have now arrived at the result. I had to capture the $result from the invoke-psuscript with a $Session:data so that I could process it further. Sometimes it can be so simple when you use the right values