Can that session info be carried across between two runs of powershell in the same 'outer' script?
Example:
1. Bash script 'a' calls out to powershell script 'b' to do something with the VM, like get status.
2. Powershell 'b' stops running and returns back to the bash script.
3. Bash script does many more things.
4. Bash script then calls out later to powershell script 'c' to do something like stop/start a vm.
5. Ideally, powershell script 'c' would be able to re-use the connection started by the 'b' script.
This is a simple example. The actual bash script is thousands of lines and is calling as many as 10 powercli scripts in a given run depending on what it does. It would be nice to cache the connection between those powershell runs.
I saw a blog entry from someone that seemed to do this trick but it relied on Windows things and did not work for powershell linux.
Original Message:
Sent: 1/24/2025 5:08:00 PM
From: LucD
Subject: RE: Faster vcenter login? Perhaps with a compile?
Besides only loading the modules you actually need, there is not a lot you can do I'm afraid.
When you need to logon multiple times, you can use the Connect-VIServer cmdlet with the Session parameter from the 2nd connect onwards.
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
------------------------------
Original Message:
Sent: Jan 24, 2025 11:31 AM
From: vwbivansc
Subject: Faster vcenter login? Perhaps with a compile?
So, I've seen and I know that a vcenter login can take several seconds or more to login. I've been told that is due to how powershell is handling the Powershell PowerCLI modules by reading and parsing them on the fly.
In a previous scripting environment for VMware SDK, I was able to connect with in 1 second. I want PowerCLI to log in faster. Sometimes I may have bigger scripts not in powershell that call out to powershell scripts multiple times. Each time it has the delay and I may have something like 30 seconds wasted if I call out enough times.
Is there some way to speed up the logins? Perhaps one of these methods?
A way to cache Logins between powershell scripts that works on Powercli for Linux?
Play with the modules picked to load? I do have the initial module loading as just "import-module Mware.VimAutomation.Core".
Pre-compile modules so Powershell has them already parsed and ready to go?
Something else?
Thanks