3 Replies Latest reply on Dec 6, 2018 9:39 AM by daphnissov

    VM Automation issue

    jmchugh1012 Lurker

      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.