VMware Cloud Community
jmchugh1012
Contributor
Contributor

VM Automation issue

We are trying to automate our installer using the following main process:

1) Revert the remote VM to a clean baseline state

2) Copy installer files to remove VM

3) Execute installer files on remote VM

The issue is that once we revert them VM in step 1, we lost our trust relationship with the domain, and we can no longer issue any powershell commands based on hostname. The only thing we can do at that point is issue VMWare powershell commands, because those don't rely on the hostname/dns/network, and are just issued directly on the VM via VCenter using the VMs label.

Therefore, our idea was to use the VMWare powershell command called Invoke-VMScript on the remote VM.  The command we're trying to run on the remote VM is a powershell command that takes the VM off the domain and puts it back on. If that worked, then we'd reestablish the trust relationship with the domain and we could continue on with the rest of the steps in our process.  When we try to do it, however, it simply does nothing (it doesn't take the machine off the domain, and doesn't record any errors either).

Here is an example of the command we're trying to run:

$scripttext = "add-computer -workgroupname WORKGROUP -restart"
Invoke-VMScript -ScriptText $scripttext -VM $vm -ScriptType ps -GuestUser <username> -GuestPassword <password>

Note that if we run this command directly on the VM (by logging in locally), it does work. It's just when we try to run it through the Invoke-VMScript command that it doesn't seem to work.  The command has to run as an administrator, but we are providing administrator credentials in the Invoke-VMScript command.

0 Kudos
3 Replies
daphnissov
Immortal
Immortal

Does whatever you're installing/testing require your Windows VM have domain membership?

0 Kudos
jmchugh1012
Contributor
Contributor

Yes it does require domain membership.

0 Kudos
daphnissov
Immortal
Immortal

Depending on your tombstone settings, one possibility I've used in the past is to delay the first snapshot right up until the moment you push that package and execute your tests. Presuming too much time hasn't elapsed, when you revert the computer object will still be valid in the domain. But if you put days in between this, that won't work.

0 Kudos