I just verified that this works for me. I’ve created an admin app token and am using Connect-PSUServer in my script to use that app token for the PSU cmdlets.
$AppToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiQWRtaW4iLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9oYXNoIjoiN2ZmMjQ4NmEtNjI2Ni00NDA5LThjZWYtYTgwYzlkZmU4NDNhIiwic3ViIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2MTc4MTMwMDMsImV4cCI6MTYyNTU4OTAwMywiaXNzIjoiSXJvbm1hblNvZnR3YXJlIiwiYXVkIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCJ9.2HKwY8No9A9uTTUHnZoAWrIatT1Dx1GZDZgntlOarko'
New-UDDashboard -Title "Hello, World!" -Content {
New-UDButton -Text 'Run Job' -OnClick {
Set-UDElement -Id 'button' -Properties @{
disabled = $true
text = "Running"
}
Connect-PSUServer -ComputerName http://localhost:5000 -AppToken $AppToken
$Job = Invoke-UAScript -Script 'GetService.ps1'
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
}
Set-UDElement -Id 'button' -Properties @{
disabled = $false
text = "Run Job"
}
} -Id 'button'
New-UDCodeEditor -Id 'codeEditor' -ReadOnly -Height 500
}