# 'win\_partition' is unable to resize the hdd

**URL:** <https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 15, 2020, 5:33am UTC](https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403 "2020-07-15T05:33:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Udayendu\_kar](https://avatars.discourse-cdn.com/v4/letter/u/87869e/32.png) [@Udayendu\_kar](https://forum.ansible.com/u/Udayendu_kar)\
**Post date:** [July 15, 2020, 5:33am UTC](https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403/1 "2020-07-15T05:33:56Z")

</div>

Disk resize code:

```auto
- name: Extend the C drive to the max space
win_partition:
partition_size: -1
partition_number: 0
disk_number: 0

```

Error message:

```auto
TASK [Extend the C drive to the max space] ******************************************************************************************************************************************************************************************************************************************* task path: /root/Windows/win-deploy.yaml:70 <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0' <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737 && echo ansible-tmp-1594746664.821915-2548-136259556554737="` echo /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737 `" ) && sleep 0' Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/windows/win_partition.ps1 <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-2331o41jvcot/tmp54wxtp0v TO /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/AnsiballZ_win_partition.ps1 <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/ /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/AnsiballZ_win_partition.ps1 && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'powershell /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/AnsiballZ_win_partition.ps1 && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/ > /dev/null 2>&1 && sleep 0' fatal: [localhost]: FAILED! => { "changed": false, "module_stderr": "\u001b[91mParserError: \u001b[0m/root/.ansible/tmp/ansible-tmp-1594746664.821915-2548-136259556554737/AnsiballZ_win_partition.ps1:151\n\u001b[96mLine |\n\u001b[96m 151 | \u001b[0m \u001b[96m\u0000\u001b[0m\u0000\u0000\u0000{\"module_entry\": \"IyFwb3dlcnNoZWxsCgojIENvcHlyaWdodDogKGMpIDIwMTg …\n\u001b[96m | \u001b[91m ~\n\u001b[91m\u001b[96m | \u001b[91munexpected token '\u0000', expected 'begin', 'process', 'end', or\n\u001b[96m | \u001b[91m'dynamicparam'.\n\u001b[0m\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }

```

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [July 15, 2020, 7:57am UTC](https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403/2 "2020-07-15T07:57:57Z")

</div>

So you are running a PowerShell module on localhost which won’t work. How have you defined your inventory, how are you targeting that host in your play?

---

<div class="post-metadata">

**Author:** ![CORLEONE](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@CORLEONE](https://forum.ansible.com/u/CORLEONE)\
**Post date:** [July 15, 2020, 8:25am UTC](https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403/3 "2020-07-15T08:25:12Z")

</div>

u001b[91munexpected token ‘\u0000’, expected ‘begin’, ‘process’, ‘end’, or\n\u001b[96m | \u001b[91m’dynamicparam’.\n\u001b[0m\n", “module\_stdout”: “”, “msg”: "MODULE

Answer is unexpected tokens

---

<div class="post-metadata">

**Author:** ![Udayendu\_kar](https://avatars.discourse-cdn.com/v4/letter/u/87869e/32.png) [@Udayendu\_kar](https://forum.ansible.com/u/Udayendu_kar)\
**Post date:** [July 15, 2020, 9:42am UTC](https://forum.ansible.com/t/win-partition-is-unable-to-resize-the-hdd/33403/4 "2020-07-15T09:42:31Z")

</div>

Finally able to connect to the windows guest after doing some setting change in the WinRM inside the guest but ‘win\_partition’ is creating a new partition instead of extending one:

# cat ../inventory

[windows]  
xxx.xxx.xxx.xxx

[windows:vars]  
ansible\_connection=winrm  
ansible\_user=Administrator  
ansible\_password=xxxxxxxxxx  
ansible\_winrm\_transport=basic  
ansible\_winrm\_server\_cert\_validation=ignore  
ansible\_port=5985

# cat disk.yaml
