title: Excecute command in vSphere Guest machine with Ansible
body: <p>I am trying to change the IP of a Windows Server 2012R2 vmware guest machine with the <a href="https://docs.ansible.com/ansible/vmware_vm_shell_module.html" rel="nofollow noreferrer">vmware_vm_shell</a> module. So far I have been able to clone the VM from a template with the <a href="https://docs.ansible.com/ansible/vsphere_guest_module.html" rel="nofollow noreferrer">vsphere_guest</a> module without problems, but when I try the following task to change the IP: </p>
  
  <pre><code>- name: Configure IP address
    local_action:
      module: vmware_vm_shell
      hostname: "{{ vcenter_hostname }}"
      username: "{{ vcenter_user }}"
      password: "{{ vcenter_password }}"
      cluster: "{{ Cluster }}"
      vm_id: "{{ machine }}"
      vm_username: "{{ machineUser }}"
      vm_password: "{{ ansible_windows_password  }}"
      vm_shell: "C:\\Windows\\System32\\WindowsPowershell\\1.0\\powershell.exe"
      vm_shell_args: " -command (Get-NetAdapter -Name Ethernet |New-NetIPAddress -InterfaceAlias Ethernet -AddressFamily IPv4 -IPAddress {{ new_machine_ip }} -PrefixLength {{ new_machine_mask_bits }} -DefaultGateway {{ new_machine_gateway }} )-and (Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses {{ new_machine_dns }})"
      vm_shell_cwd: "C:\\Windows\\Temp"
      validate_certs: False
  </code></pre>
  
  <p>The response from Ansible is <code>"msg": "File &lt;unspecified filename&gt; was not found"</code>.</p>
  
  <p>I get the same error when I try to run the <code>execute_program_in_vm.py</code> script from <a href="https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/execute_program_in_vm.py" rel="nofollow noreferrer">pyvmomi-community-samples</a>: <code>Caught vmodl fault : File &lt;unspecified filename&gt; was not found</code> </p>
  
  <p>The vmware user I have has all the <code>Guest Operations</code> permissions set. What am I missing here? </p>
  
  <p>PS: I followed <a href="http://devopspecialist.co.uk/2016/08/04/ansible-tower-and-vsphere-talking-to-a-windows-server-2012-with-no-ip-address/" rel="nofollow noreferrer">this guide</a>. </p>