VMware Cloud Community
Sirry
Enthusiast
Enthusiast

Running batch file on guest VM using vCD?

There are examples where I can execute batch files on guest OS through vCenter, but I don't know how to do it through vCD. Are there any examples of how this can be done? Thanks in advance!

Tags (3)
0 Kudos
3 Replies
Burke-
VMware Employee
VMware Employee

You have a couple options for this:

1) Preferred: Setup your batch file in the Guest Customization of your vApp when you are ready to deploy, I provided an example of this in the Custom Deploy vApp package found on the Documents tab of this Forum - in that example, I add a specified domain user to the local administrators group of a windows VM.

2) (Requires SYSTEM ADMIN access to vCloud Director): Lookup the VC:VirtualMachine that matches the selected vCloud:VM object, once located, use the vCenter Guest Operations calls to perform your tasks.

Other options could include things like calling PowerShell to do things for you, SSH, vCenter Configuration Manager, etc...

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Sirry
Enthusiast
Enthusiast

Thank you Burke! Is there a way to automate #2? I have tried a little bit, and have received a Moref VM #, but I'm not sure how to proceed after that. I am trying to avoid using too many plugins/etc outside of vco if possible.

0 Kudos
Burke-
VMware Employee
VMware Employee

If you have the MoRef (and you are using a single vCenter), then you can get the VC:VirtualMachine object like this:

var XPath = "xpath:id='"+vmMoRef+"'";

var VMs  = VcPlugin.getAllVirtualMachines(null, XPath);

var vCenterVM = VMs[0];

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos