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
------------------------------