I am trying to run another script after a scheduled job finishes. I used
Invoke-UDScript -Script 'myScript.ps1'
Output is showing unauthorized. According to the documentation I should not need to use an app token in this case? Maybe someone can help me out, I can generate a token but would rather not have to renew it every year.
You can also call UA scripts from UA scripts. When running a job in UA, you don’t need to define an app token or the computer name manually. These will be defined for you. You can just call Invoke-UAScript within your script to start another script. Both jobs will be shown in the UI. If you want to wait for the script to finish, use Wait-UAJob .
I also noticed the ‘Triggers’ option on the side of the UA that I have not explored. I went ahead and added the trigger there, I do not need to see the output of the script, but will I see some kind of notice that the trigger indeed did work?
@adam
EDIT:
Thank you! I figured it out.
I got confused (too early, not enough coffee) when I was reading the dialog for adding a new triggered. I figured it was setup like 'When this script, does this, execute this" and not vice versa. I seen the trigger in my log. Thank you again!
Hi Adam, I am not keen on the idea of New-PsuTrigger at the end of a script due to error handling (although i see there are triggers to help with this), ideally i would have a Trigger setup for JobComplete that triggers the same job again, so no matter how long the job takes, it then runs again (i use this for REST calls which can take 5 seconds, can take 1 min).
When I try this, I manually trigger the script, On completion it then indeed does trigger the script again, but when that script finishes it does not continue to trigger.