VMware Cloud Community
sejohlun
Contributor
Contributor

Use Invoke-VMScript for OU move and installation of app etc

1. Per default our deployment puts all our new servers in the default OU in our AD. I have found it very difficult to move the computer account from one OU to another. I have used dsmove.exe and the vCenter build in Customization Spec with no luck.
Can I use Invoke-VMScript in our deployment script to execute this move? We join our member servers using the Customization spec as well. But maybe it work best to use the script there as well.....

 the best solution would be to be promted like:

Join Domain? Yes --->  Code to join domain No----> Workgroup

If Yes....the scripts creates or moves the computer accout to our "Deployment OU"

2. I also would like to install our OP5 monitoring agent in this script.  Is this possible?
I have a msiexec string I would like to use:
msiexec.exe /quiet /i "%~dp0NSCP-0.5.2.35-x64.msi" /norestart MONITORING_TOOL=OP5 CONF_CAN_CHANGE=1 NSCLIENT_PWD="password" ALLOWED_HOSTS="ip"

3. I also would like to add an user interaction where I can choose what Network to deploy the VMs.

I have attached my deployment script.....

 

 
0 Kudos
1 Reply
LucD
Leadership
Leadership

You can use the Invoke-VMScript for the first 1, but there are a couple of caveats.

  • Invoke-VMScript needs the VMware Tools to be running. If that is not yet the case during the customisation process, the cmdlet will not work.
    • As a solution run those scripts after the customisation script has completed and after you check that the VMware Tools are running
  • If UAC is active, you will not be able to run commands, via Invoke-VMScript, that require an elevated account
    • UAC is a security mechanism, and it would be a weak one if you could bypass it with code like this

The network selection (your 3th point) can be prompted and set with the New-VM or Set-VM cmdlet.
It has nothing to do with the Guest OS, but assigns the VM to a specific Portgroup.

Setting the network settings inside the Guest OS, IP address/network mask/gateway..., can be done through the OSCustimozationSpec.

For that, you use the New-OSCustomizationNicMapping or Set-OSCustomizationNIcMapping cmdlets.

There is a great set of blog post on the use of OSCustomizationSpec.

Part 1, part 2 and part 3.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos