set-ItemProperty -Path 'HKLM:System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
set-ItemProperty -Path 'HKEY_LOCAL_MACHINE:System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
set-ItemProperty -Path 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
But none of them work. Got the following error with the option you suggested.
fatal: [10.10.3.170]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"_raw_params": "set-ItemProperty -Path 'HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Terminal Server' -name \"fDenyTSConnections\" -Value 0"}, "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\">set-ItemProperty : Cannot find path 'C:\\Users\\Administrator\\HKEY_LOCAL_MACHINE\\_x000D__x000A_</S><S S=\"Error\">System\\CurrentControlSet\\Control\\Terminal Server' because it does not exist._x000D__x000A_</S><S S=\"Error\">At line:1 char:1_x000D__x000A_</S><S S=\"Error\">+ set-ItemProperty -Path _x000D__x000A_</S><S S=\"Error\">'HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Term ..._x000D__x000A_</S><S S=\"Error\">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S=\"Error\">~~~_x000D__x000A_</S><S S=\"Error\"> + CategoryInfo : ObjectNotFound: (C:\\Users\\Admini...Terminal Serv _x000D__x000A_</S><S S=\"Error\"> er:String) [Set-ItemProperty], ItemNotFoundException_x000D__x000A_</S><S S=\"Error\"> + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetIt _x000D__x000A_</S><S S=\"Error\"> emPropertyCommand_x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</S></Objs>", "stdout": "", "stdout_lines": []}
I have no doubt if I used the win_regedit it would work. But Im trying to figure out why Ansible is not able to run a simple Powershell script from a playbook?
Why am I able to run that script successfully from the machine, but it fails when Ansible ties to execute it from a playbook.
This is the part of the error that concerns me:
<S S=\"Error\">set-ItemProperty : Cannot find path 'C:\\Users\\Administrator\\HKEY_LOCAL_MACHINE\\_x000D__x000A_</S>
Why is Ansible trying to find the path in C:\\ when this is a registry script?
Any ideas would be appreciated.
Cheers
Mark