Calling a Script job from a dashboard

I am on 3.7.6 currently.

I have a script that runs and a schedule and caches the data in a variable I then retrieve in a dashboard for display.

I am trying to add an add-hoc refresh of the table with a button and a call to the script but the following command doesn’t work.

Invoke-PSUScript -Name ‘MyScript.ps1’ -Integrated -Wait

The Script and the dashboard are both running under the integrated environment.

Am I doing something wrong?

The docs seem to support the syntax above but the call to Invoke-PSUScript throws the following error. “Cannot retrieve the dynamic parameters for the cmdlet.”

That should certainly work.

What happens when you call it like this:

$Script = Get-PSUScript -Name 'MyScript.ps1' -Integrated
Invoke-PSUScript -Script $Script -Integrated -Wait

With the above I get a cannot bind argument to parameter script because it is null.

If I run just Get-PSUScript it lists all the scripts as expected.

I tried dropping the -integrated from Get-PSUScript -Name and that worked so it must be something to do with the integrated switch.

Spoke too soon it didnt fix it :confused:

OK so this seems to work.

$Script = Get-PSUScript | Where-Object {$_.Name -eq "Set-SlackDisabledUsers.ps1"} 
Invoke-PSUScript -Script $Script -Integrated | Wait-PSUJob
1 Like