Display on page results as scripts run

Product: PowerShell Universal
Version: 1.4.6

Not quite sure how to explain this, used UD a couple of years ago and have just got back to it
I am creating a New-UDStepper and in the -onfinish section I want to display progress as each script runs

                        if(($Session:ApplicationInstallOrUninstall.Action) -eq 'Install')
                        { 
                        New-UDAlert -severity 'info'-text    "Adding $($Session:UserOrDeviceSelected.Device)  to Collection "
                        New-UDAlert -severity 'info'-text "Please wait - this may take a minute or two"  
                        New-UDAlert -severity 'success'-text  "Device  appears in Collection"
                        New-UDAlert -severity 'info'-text "Initiating Computer Policy update to  Device"
                        New-UDAlert -severity 'success'-text "Initiated - If the device is online, the Application it should start installing in 5 minutes"
                        New-UDAlert -severity 'info'-text "Check Software Center on Device "
                        }

As an example if I put say start-sleep 5 between each New-UDAlert

                        if(($Session:ApplicationInstallOrUninstall.Action) -eq 'Install')
                        { 
                        New-UDAlert -severity 'info'-text    "Adding $($Session:UserOrDeviceSelected.Device)  to Collection "
Start-Sleep 5
                        New-UDAlert -severity 'info'-text "Please wait - this may take a minute or two"  
Start-Sleep 5
                        New-UDAlert -severity 'success'-text  "Device  appears in Collection"
Start-Sleep 5
                        New-UDAlert -severity 'info'-text "Initiating Computer Policy update to  Device"
Start-Sleep 5
                        New-UDAlert -severity 'success'-text "Initiated - If the device is online, the Application it should start installing in 5 minutes"
Start-Sleep 5
                        New-UDAlert -severity 'info'-text "Check Software Center on Device "
                        }

, the end result is a page taking 30 seconds longer to load, when what I want is for each New-UDAlert to appear on the page every 5 seconds

To answer my own question,
I created a script
I then invoked that script in the dashboard.
As the Script ran it outputs progress to a log filename based on a GUID i created and passed as a parameter.
then i created new-uddynamic element that read the log file using get-content.
Still working on getting get-content to show line by line , but that is a minor thing, i will probably use New UDAlert for my purposes

$guid = [guid]::NewGuid()

                $ApplicationRequest = New-Object –TypeName PSObject –Prop ([ordered]@{
                    guid            = $guid
                    ApplicationName = $ApplicationtoManage.ApplicationName
                    Action          = 'Install'
                    Device          = 'HWL1234'
                    User            = 'John Doe'
                    Requestor       = "Anonymous"
                    ADGroup         = $ApplicationtoManage.ADGroup
                    Approval        = $ApplicationtoManage.Approval
                    CollectionType  = $ApplicationtoManage.CollectionType
                    DeviceOrUser    = $ApplicationtoManage.DeviceOrUser
                    Install         = $ApplicationtoManage.Install
                    IOIKey          = $ApplicationtoManage.IOIKey
                    IOIType         = $ApplicationtoManage.IOIType
                    IOIValue        = $ApplicationtoManage.IOIValue
                    Uninstall       = $ApplicationtoManage.Uninstall
                    })

                    $Session:InvokeResult = Invoke-PSUScript -name 'SubmitApplicationRequest.ps1' -integrated -ApplicationRequest $ApplicationRequest 

                    New-UDAlert -severity 'info' -text  "$Session:InvokeResult"
                    $LogPath = 'C:\temp\logs\ApplicationRequest\'
                    $LogFileName = "$($ApplicationRequest.guid).log"
                    $LogFullFileName = $LogPath + $LogFileName
                    
                    New-UDCard -id 'Bob' -Content {
                    New-UDDynamic -ID 'AppProcess' -Content {
                     $Session:ResultfileContent = get-content -path $LogFullFileName
                     foreach ($Session:Line in $Session:ResultfileContent )
                     {
                        New-UDTypography  "$Session:Line"  
                     }
                     
                     Show-UDToast -message "$Session:ResultfileContent"
                    } -AutoRefresh -AutoRefreshInterval 5
            }
1 Like