Preload Modules in environments


For me it is a general question on how PSU deals with RunSpaces in background. But let me outline my case first.

I have an endpoint calling a PSU Script with Invoke-PSUScript.
The PSU Script heavily deals with VMWare infrastructure, meaning:

  • Importing the heavy VMWare Module stack “VMware.VimAutomation.Core” which
    takes around 1 Minute to load ! I know that there are workarounds by disabling
    the lookup for “publishers certificate revocation CRLs” which brings it down to
    15 seconds.
    Works. But is it a good idea ? No.
  • Connecting to VMWare vCenter and VMWare Horizon Portals
  • Executing VMWare related CmdLets (the workload)

My question is; how do you deal with powershell runspaces in background.
Do you keep one per environment open and use AddScript/AddCommand/… to execute always in the same runspace or do you open a new runspace each time a PSU-Script is executed?
Are you using the standard [System.Management.Automation.Powershell] assemblies internally?

I ask because I do a lot with that stuff myself. :smirk:

So the real question is.

Would it be possible to tell PSU that the heavy “VMware.VimAutomation.Core” is loaded ONCE and not every time when a PSU-Script is loaded.


Product: PowerShell Universal
Version: 4.2.13
1 Like