Is it possible to create and modify UA scripts from dashboard hosted in IIS

Dear Adam,

i have a licensed PSU hosted in IIS and i would like an example on how to create and schedule a UA script from the dashboard by for example a button click without the need to access the UA GUI.

So far i think it will require an apptoken which is fine but could not find an example clear enough to do so.

The goal is to have a button in UD to create and schedule a UA script to be executed in future date for one time only.
a step by step example will be much appreciated.

Thank you.

Product: PowerShell Universal
Version: 1.5.16

Here’s an example of creating a script and scheduling it with a button.

$AppToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiQWRtaW4iLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9oYXNoIjoiMmMwNGEwYzAtMzcyZi00OWYzLWEyYTctNDNhNTQ1MTIzNDM3Iiwic3ViIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2MjAzOTkzNzAsImV4cCI6MTYyMjk5MTM3MCwiaXNzIjoiSXJvbm1hblNvZnR3YXJlIiwiYXVkIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCJ9.E4qAY60ev_dQtilSguoeh1UEY7qefMpp6lbinGpBG1w'
New-UDDashboard -Title "Hello, World!" -Content {
    New-UDButton -Text 'Create and schedule script' -OnClick {
        Connect-PSUServer -ComputerName 'http://localhost:5000' -AppToken $AppToken
       $Script = New-PSUScript -Name 'Script1.ps1' -ScriptBlock { 'Get-Process' }
       New-PSUSchedule -Script $Script -OneTime (Get-Date).AddHours(1)
    }
}