# Ansible works with hyper-v. permission denied

**URL:** <https://forum.ansible.com/t/ansible-works-with-hyper-v-permission-denied/28057>\
**Category:** Ansible Project\
**Created:** [July 16, 2018, 4:16pm UTC](https://forum.ansible.com/t/ansible-works-with-hyper-v-permission-denied/28057 "2018-07-16T16:16:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mli103](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mli103](https://forum.ansible.com/u/mli103)\
**Post date:** [July 16, 2018, 4:16pm UTC](https://forum.ansible.com/t/ansible-works-with-hyper-v-permission-denied/28057/1 "2018-07-16T16:16:21Z")

</div>

I would like to export vm running on hyper-v to a remote shared file system. I make it manually, by saying that is I right clicked powershell and choosing “run as administrator” and run the command in the cmd. But I failed when run my ansible playbook with the same command with the error of : "Export-VM : Failed to create export directory. I use kerberos to authenticate.

The user I used in ansible to talk to hyper-v hosts does have the shared file system access permission. My playbook like below. The DIR variable is the path to the remote shared file system.

Anybody has an idea to workaround it? The administrator here is local administrator user. Should I use domain admin user here to escalate the right? .

- hosts: xxxx  
gather\_facts: False  
become\_method: runas

vars:  
ansible\_become\_password: xxxxx

tasks:

- name: Export the vm to remote directory  
win\_shell: Export-VM -Name {{ VM }} -Path {{ DIR }}  
become: yes  
become\_user: Administrator

Thanks

Ming

---

<div class="post-metadata">

**Author:** ![mli103](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mli103](https://forum.ansible.com/u/mli103)\
**Post date:** [July 16, 2018, 7:15pm UTC](https://forum.ansible.com/t/ansible-works-with-hyper-v-permission-denied/28057/2 "2018-07-16T19:15:40Z")

</div>

Fixed it by added below as variables

```auto
    ansible_become: yes
    ansible_become_method: runas
    ansible_become_user: DOMAIN\user
    ansible_become_pass: Password01
    ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only

```
