Slow Invoke-PSUScript

We are seeing very slow load times with Invoke-PSUScript. It appears 10 to 20 times slow than when run on the PSU server’s pwsh 7 interface. It is consistent regardless if data is coming from SQL or CSV. We have learned about about how to show progress via write-progress and show-UDToast and leveraging cached scoped to prevent reloading but don’t know if your experience is normal or we should be troubleshooting something. We moved the server from 4 cores to 8 cores and see the additional powershell executables on the servers better leveraging the additional cores but anyone job still seems slow. The scripts we are running are fairly straight forward scripts leveraging invoke-sql to return or write between 20 and 10000 items. This isn’t related to UD-Table loading which we have found documentation how to speed that piece up.

Basic app is about 25 import scripts manually refreshed via some buttons in a table. Also options to delete import data, re-import, show data, and run some standard translations. Not a deal killer but always looking to optimize users time.

Prior to building the app it was a serries of scripts manually run via powershell ISE and much faster…although burdon of running them fell on me.
Any help on what “normal” is would be helpful or steps I can do to help determine this.

Every object that is returned in a script is serialized to CliXml using the PSSerializer class. This can be a pretty big bottle neck if you are returning thousands objects.

A couple things you could consider:

  • Flatten and prune your objects are much as possible using Select-Object.
  • Consider just running the script directly (without Invoke-PSUScript)

Adam thanks. Does running the script directly mean dot sourcing within the dashboard or something else?what path would I use to access the scripts in the PSU Script Folder? Also does the “write progress” from the script get passed into the dashboard’s native process bar work if we avoid Invoke-PSUScript?

Some of the scripts have the Param($variable1, $variable2). Would we turn the script into a function, dot source, then call that function in the dashboard.

FYI - Our team really appreciates getting feedback directly from developer/architect. You are doing an amazing job providing valuable training content and answers to our questions.