Jenkins windows service pipeline

Jenkins setup: Jenkins 2.252

I am trying to run Jenkins pipeline to start and stop windows service.But facing below error .

Pipeline code :pipeline {
agent any

stages {
    stage('Start Windows Service on Remote Server') {
        steps {
            script {
                def remoteServer = ''
                def remoteUsername = 'EBLXXXXX'
                def remotePassword = 'XXXX'

                // Start the Windows service on the remote server
                    remote: remoteServer,
                    user: remoteUsername,
                    password: remotePassword,
                    command: "sc start metricbeat"



ERROR: Running on Jenkins in C:\Program Files\Jenkins\workspace\JenkinsWindowsJob [Pipeline] { [Pipeline] stage [Pipeline] { (Start Windows Service on Remote Server) [Pipeline] script [Pipeline] { [Pipeline] sshCommand WARNING: Unknown parameter(s) found for class type ‘org.jenkinsci.plugins.sshsteps.steps.CommandStep’: password,user [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline java.lang.ClassCastException: class org.jenkinsci.plugins.sshsteps.steps.BasicSSHStep.remote expects interface java.util.Map but received class java.lang.String at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce( at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters( at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate( at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep( at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(

read the manual:

how to define server, user and password and pass it to the step

Also – it might be better to use sc.exe rather than plain sc, so that the command works even if the default shell of the OpenSSH server is PowerShell rather than cmd. PowerShell has sc as a built-in alias for Set-Content.