Question

I wrote a powerCLI script that can automatically deploy a new VM with some given parameters. In few words, the script connects to a given VC and start the deployment from an existing template.

Can I regulate the number of instances of my script that will run on the same computer ? Can I regulate the number of instances of my script that will run on different computers but when both instances will be connected to the same VC ?

To resolve the issue i thought of developing a server side appilcation where each instance of my script will connect to, and the server will then handle all the instances , but i am not sure if such thing is possible in powerCLI/Powershell.

Was it helpful?

Solution

Virtually anything is poshable, or so they say. What you're describing may be overkill, however, depending on your scenario. Multiple instances of the same script will each run in its own Powershell process. Virtual Center allows hundreds of simultaneous connections. Of course the content or context of your script might dictate that it shouldn't run in simultaneous instances. I haven't experimented, but it seems like there are ways to determine the name of running Powershell scripts. So if you keep the script name consistent on each computer, you could probably build in some checks along the lines of the linked answer.

But depending on your particulars, it might be easier to go a different way. For example, if you don't want the script to run simultaneously because you have hard-coded the name of a new-osCustomizationSpec, for example, a simple\klugey solution might be to do a check for that new spec, and disconnect/exit/rollback if it exists. A better solution might be to give the new spec a unique name. But the devil is in the details. Hope that helps a bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top