Vmware/vcenter info through api slow, how to load on startup?

Hi All,

Im using the following code in my API endpoint:

. D:\Variables\Loadvariables.ps1
(above loads (for example) credentials to use for the following command

Connect-VIServer -server x -credential $cred
get-vm $vm

Problem is, every time i need to get VM info, the connect-viserver needs to run, because the login is not global and i cannot reuse get-vm instantly.

Is there a way to pre-load the modules and have the variables and connections exist for the complete environment / api?

Product: PowerShell Universal
Version: 1.4.6