VMware Cloud Community
eb8945
Contributor
Contributor
Jump to solution

vRA - "Run Program in Guest"

I wanted to reach out and see if anybody else was running into this problem.  I'm trying to execute some PowerShell scripts on the VM after it is built in the PRE MachineActivated phase.  I'm using the built-in Orchestrator workflow of "Copy file from VCO to guest" and that seems to work reliably 100% of the time.

However, when I use the built-in Orchestrator workflow called "Run program in guest" I seem to be getting mixed results.  Sometimes the PowerShell scripts execute... sometimes they don't.  I can't seem to get a good reason on why they do or don't execute.  It seems to be at random... I'm not sure if Orchestrator is having issues contacting VMware Tools?  However, everything always green checkmarks in Orchestrator.. as far as vRO is concerned the script ran successfully.

I have set those PowerShell scripts up to auto-delete after they run on the server.  If the script doesn't run it is still on the filesystem of the VM that was deployed.  Does anyone have a better mechanism for this?

In my first try I used a secured SSL connection to our PowerShell server to have PowerShell connect to vCenter and then try to use the Invoke Powershell commands for running something off the VM.  That also seemed to be not reliable.. it would sometimes run.. sometimes fail.

Is there a preferred, supported, mechanism for running custom scripts on a VM after the box is built?  I'm willing to modify the scripts as necessary but I need to support Windows Server 2012R2, Server 2016, and Server 2019.  Right now Server 2016 seems to be the biggest problem child... and I haven't even begun testing with Server 2019 yet.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
daphnissov
Immortal
Immortal
Jump to solution

Since you're doing this through vRA, there are a few methods for installing software via running a PowerShell script.

  1. vRA guest agent (gugent) has a built-in ability to run a script on a machine. This doesn't involve vRO. Script can either pre-exist, or you can build somewhat of a framework to first mount a script repo and call the one you want. This option, while available in all vRA licenses, is a bit unwieldy.
  2. vRA software components. Requires vRA Enterprise license. You can just paste in  your PowerShell code directly and have it execute on the deployed machine. Lots of other abilities enabled by this including things like property binding and computed properties. Also does not involve vRO.
  3. Guest Script Manager. Free, community-supported only package. Stores scripts as Resource Elements making it fairly easy to call them on a destined machine. Has known issues and hasn't been updated in a while. Run directly from vRO. You're required to set all the vRA plumbing up for this to work.
  4. SovLabs Lifecycle Components Toolkit. If you don't have a vRA Enterprise license, this is the one I like the best. Allows you to execute a script on a deployed node (and have it automatically remove the script), or on another node. Either one allows you to easily tap into custom properties. Runs through vRO but requires no vRO maintenance or configuration, no EBS subscripts, nothing you have to configure other than a couple vRA catalog item requests to fill out your script info and related stuff. This one is probably the most robust of any vRO method you'll find and also fully supported, tested, and maintained.

View solution in original post

0 Kudos
2 Replies
daphnissov
Immortal
Immortal
Jump to solution

Since you're doing this through vRA, there are a few methods for installing software via running a PowerShell script.

  1. vRA guest agent (gugent) has a built-in ability to run a script on a machine. This doesn't involve vRO. Script can either pre-exist, or you can build somewhat of a framework to first mount a script repo and call the one you want. This option, while available in all vRA licenses, is a bit unwieldy.
  2. vRA software components. Requires vRA Enterprise license. You can just paste in  your PowerShell code directly and have it execute on the deployed machine. Lots of other abilities enabled by this including things like property binding and computed properties. Also does not involve vRO.
  3. Guest Script Manager. Free, community-supported only package. Stores scripts as Resource Elements making it fairly easy to call them on a destined machine. Has known issues and hasn't been updated in a while. Run directly from vRO. You're required to set all the vRA plumbing up for this to work.
  4. SovLabs Lifecycle Components Toolkit. If you don't have a vRA Enterprise license, this is the one I like the best. Allows you to execute a script on a deployed node (and have it automatically remove the script), or on another node. Either one allows you to easily tap into custom properties. Runs through vRO but requires no vRO maintenance or configuration, no EBS subscripts, nothing you have to configure other than a couple vRA catalog item requests to fill out your script info and related stuff. This one is probably the most robust of any vRO method you'll find and also fully supported, tested, and maintained.
0 Kudos
eb8945
Contributor
Contributor
Jump to solution

Wow thank you so much!  I'm still somewhat new to the vRA game... and I really appreciate this.  I'll try to figure out which option is best for us.

0 Kudos