I have a dashboard that technicians can access to kick off an script in PSU.
This launches a PowerShell script that calls an external .BAT file using Invoke-Command.
It has worked wonders, until 2.4.0. Holding off on 2.5.X, because I was not sure if the method I am doing would break further.
What happens is the techs hit ‘Run’, the button changes to ‘Running’ and the output CodeEditor flashes and I can briefly see it populating the output of the script, then when it is done; the Window is empty.
New-UDButton -Text 'Run' -OnClick {
Set-UDElement -Id 'button' -Properties @{
disabled = $true
text = "Running"
}
Connect-PSUServer -ComputerName http://localhost:5000 -AppToken $AppToken
$Job = Invoke-UAScript -Script 'Redefine.ps1' -OS $os -storeNum $storeNum
while($Job.Status -ne 'Completed')
{
Start-Sleep 1
$Output = (Get-UAJobOutput -Job $Job).Data -join ([Environment]::NewLine)
Set-UDElement -Id 'codeEditor' -Properties @{
code = $Output
}
$Job = Get-UAJob -Id $Job.Id
}
Show-UDToast -Message "Job ran successful! Check output for status." -Duration 10000
Set-UDElement -Id 'button' -Properties @{
#disabled = $false
text = "Finished"
}
} -Id 'button'
Product: PowerShell Universal
Version: 2.4.0