VMware Cloud Community
bl44t
Contributor
Contributor

Run a Powershell script after template deployment

Hi all,

 

 

We have a powershell script, that needs to be runned as a domain admin in order to create some AD groups.

We want to be able to have this script runned after the VM deployment is finished. However, this script is then runned as the local admin of that system. Not as a domain admin. How can I solve this?

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

You didn't specify if you use an OSCustomizationSpec with the deployment.

In any case, you can wait for the completion of an OSCustomization by looking for the CustomizationSucceeded event.

See also Waiting for OS customization to complete

If you don't use an OSCustomization, you can just wait for the VMware Tools to become available after the poweron of the VM.

After that you can use Invoke-VMScript to run a script inside the Guest OS of the VM.


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

Reply
0 Kudos
bl44t
Contributor
Contributor

Hi, I am using VM Customization Specifications from the web interface. Then I have selected commands to run once

I can get the script to run, however it is as the local account, not as a domain account

Reply
0 Kudos
LucD
Leadership
Leadership

And what is the problem/question?


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

Reply
0 Kudos
bl44t
Contributor
Contributor

How can I make my script run as a domain admin instead of a local administrator

Reply
0 Kudos
LucD
Leadership
Leadership

Is the Guest OS at that point joined to the domain?
If not, you are restricted to a local account.

This is the same if you would be doing this on a physical machine


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

Reply
0 Kudos