Trying to "dir /b c:\Temp" using a playbook or via adhoc and getting the error message below. It seems to have a problem with "/b" in "Dir /b C:\Temp"
- hosts: all
gather_facts: yes
tasks:
- win_shell: dir /b C:\Temp
FAILED! => {"changed": true, "cmd": "dir /b C:\\Temp", "delta": "0:00:00.839042", "end": "2017-10-11 08:22:02.820065", "failed": true, "rc": 1, "start": "2017-10-11 08:22:01.981022", "stderr": "dir : Cannot find path 'C:\\b' because it does not exist.\r\nAt line:1 char:65\r\n+ [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b \r\nC:\\Temp\r\n+ \r\n~~~~~~~~~~~~~~\r\n + CategoryInfo : ObjectNotFound: (C:\\b:String) [Get-ChildItem], I \r\n temNotFoundException\r\n + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh \r\n ildItemCommand", "stderr_lines": ["dir : Cannot find path 'C:\\b' because it does not exist.", "At line:1 char:65", "+ [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b ", "C:\\Temp", "+ ", "~~~~~~~~~~~~~~", " + CategoryInfo : ObjectNotFound: (C:\\b:String) [Get-ChildItem], I ", " temNotFoundException", " + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh ", " ildItemCommand"], "stdout": "", "stdout_lines": []}
ansible -i poc-win all -m raw -a "dir /b C:\Temp"
| FAILED | rc=1 >>
dir : Cannot find path 'C:\b' because it does not exist.
At line:1 char:1
+ dir /b C:\Temp
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\b:String) [Get-ChildItem], I
temNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh
ildItemCommand
ansible -i poc-win all -m win_shell -a "dir /b C:\Temp"
| FAILED | rc=1 >>
dir : Cannot find path 'C:\b' because it does not exist.
At line:1 char:65
+ [Console]::InputEncoding = New-Object Text.UTF8Encoding $false; dir /b
C:\Temp
+
~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\b:String) [Get-ChildItem], I
temNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCh
ildItemCommand