The attached script is used with vCommander® Execute Script steps in completion workflows to add the deployed VM to a specified computer group in Active Directory.


Requirements



Download and extract the script to your vCommander application server. Embotics recommends storing all scripts called by vCommander in a single location, using sub-folders to identify the functions of scripts. With the script with which this article is concerned extracted to C: on the vCommander server, the file system will look like this:


  • C:\scripts\ad\add_to_AD_Group.ps1


The script requires a minor edit before it will work in your environment.



Replace adtest with the name of the computer group to which deployed VMs will be added.


Configuring a Completion Workflow


You can create a new completion workflow to handle this functionality or add a step to an existing completion workflow. Add an Execute Script step as described below:



Step Name: Add to Computer Group

Step Execution: Always execute (or configure an appropriate condition on which to execute)

Timeout: 300

Script Output: Capture script output as comment

When Step Fails: Mark workflow step as failed: do not proceed

Command Line

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy bypass & "c:\scripts\add_to_AD_Group.ps1 #{target.deployedName}"