I am trying to create a service of type kernel on a remote windows 10 machine from a linux ansible controller machine. To create a service I’m using sc create type=kernel binpath=c:\path command.
Ansible playbook for creating a service:
- hosts: windows
tasks: - name: Create temp service
raw: sc create temp type=kernel binpath=c:\path\
And I’m getting the following error:
TASK [Create temp service on windows] ****************************************
fatal: [10.x.x.x]: FAILED! => {“changed”: false, “failed”: true, “rc”: 1, “stderr”: “#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="[http://schemas.microsoft.com/powershell/2004/04\](http://schemas.microsoft.com/powershell/2004/04/)”><Obj S="progress" RefId="0"><TN RefId="0">System.Management.Automation.PSCustomObjectSystem.Object<I64 N="SourceId">1<PR N="Record">Preparing modules for first use.0-1-1Completed-1 <S S="Error">Set-Content : A positional parameter cannot be found that accepts argument ‘type=kernel’.x000D__x000A<S S="Error">At line:1 char:1_x000D__x000A_<S S="Error">+ sc create temp type=kernel binpath=c:\windows\ …x000D__x000A<S S="Error">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~x000D__x000A<S S="Error"> + CategoryInfo : InvalidArgument: ( [Set-Content], ParameterBindingException_x000D__x000A_<S S="Error"> + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand_x000D__x000A_<S S="Error"> x000D__x000A", “stdout”: “”, “stdout_lines”: }
What could be the exact reason? Or is there any other of creating a service on a windows machine?