# Ansible 2.0 - Move file on remote Windows machine fails using raw

**URL:** <https://forum.ansible.com/t/ansible-2-0-move-file-on-remote-windows-machine-fails-using-raw/20228>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [January 15, 2016, 4:25pm UTC](https://forum.ansible.com/t/ansible-2-0-move-file-on-remote-windows-machine-fails-using-raw/20228 "2016-01-15T16:25:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [January 15, 2016, 4:25pm UTC](https://forum.ansible.com/t/ansible-2-0-move-file-on-remote-windows-machine-fails-using-raw/20228/1 "2016-01-15T16:25:13Z")

</div>

It appears that the only way to copy or move files on remote Windows Servers requires the use of  
the raw module (or uploading your own PS script). However, I can’t get even a basic move to work.

`

- name: Configure the Windows Server 2012 R2 instance  
hosts: ec2hosts  
vars:  
workdirectory: ‘C:\mystuff’

- name: move config file  
raw: move /y {{ workdirectory }}\config\junk.conf {{ workdirectory }}\config\smtp.conf

`

When this executes, I get this response:

`TASK [move config file] ********************************************** task path: /Users/me/build_win.yml:99 <52.xx.xx.xx> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 52.xx.xx.xx <52.xx.xx.xx> EXEC move /y C:\mystuff\config\junk.conf C:\mystuff\config\smtp.conf fatal: [52.xx.xx.xx]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"_raw_params": "move /y C:\\mystuff\\config\\junk.conf C:\\mystuff\\config\\smtp.conf"}, "module_name": "raw"}, "rc": 1, "stderr": "#< CLIXML\r\n<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"><S S=\"Error\">Move-Item : A positional parameter cannot be found that accepts argument _x000D __x000A_</S><S S=\"Error\">'C:\\mystuff\\config\\smtp.conf'._x000D__ x000A_</S><S S=\"Error\">At line:1 char:1_x000D __x000A_</S><S S=\"Error\">+ move /y _x000D__ x000A_</S><S S=\"Error\">C:\\mystuff\\config\\smtp.conf ..._x000D __x000A_</S><S S=\"Error\">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__ x000A_</S><S S=\"Error\">~~~ _x000D__x000A_</S><S S=\"Error\"> + CategoryInfo : InvalidArgument: (:) [Move-Item], ParameterBindi _x000D__x000A_</S><S S=\"Error\"> ngException_x000D __x000A_</S><S S=\"Error\"> + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell _x000D__ x000A_</S><S S=\"Error\"> .Commands.MoveItemCommand_x000D __x000A_</S><S S=\"Error\"> _x000D__ x000A_</S></Objs>", "stdout": "", "stdout_lines": []}`

Note that if I go to the Windows Server and paste in the command:

`move /y C:\mystuff\config\junk.conf C:\mystuff\config\smtp.conf`

…it works fine.

The PS error message above:

`Move-Item : A positional parameter cannot be found that accepts argument _x000D__x000A_`

…seems to be saying there is a problem with a cr/lf ?

I’m stumped…

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [January 15, 2016, 5:31pm UTC](https://forum.ansible.com/t/ansible-2-0-move-file-on-remote-windows-machine-fails-using-raw/20228/2 "2016-01-15T17:31:00Z")

</div>

So, the raw module runs commands (by default) using Powershell on Windows. Powershell won’t

run DOS commands (like move and copy) without some coaxing.

To get it to work, I had to do it like this:

`

- name: move config file  
raw: CMD /C “move /y {{ workdirectory }}\config\junk.conf {{ workdirectory }}\config\smtp.conf”  
`

Using “CMD” tells Powershell not to parse the string that comes after in quotes.

This is a pretty good discussion:

[http://blogs.technet.com/b/josebda/archive/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters.aspx](http://blogs.technet.com/b/josebda/archive/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters.aspx)
