Buy Me a Coffee

Tuesday, October 18, 2016

How to run a batch script on virtual machine using vmware tools



Here is an example of how to run a batch script on virtual machine using vmware tools.

in this example the batch script will query the "Remote Desktop Services" (TermService) service.


* you will have to download VMware PowerCLI

1. execute VMware PowerCLI.
2. Connect to the VC using the following command:
Connect-VIServer -Server %VCNAME% -User %USERNAME% -Password %PASSWORD%

3. Run the following via PowerCLI (Define the script which about to be executed).
 $script = 'sc query TermService'

4. Run the following via PowerCLI

Invoke-VMScript -Scripttype bat -ScriptText $script -VM $VMNAME$


No comments:

Post a Comment