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 = '10.224.14.87'
                def remoteUsername = 'EBLXXXXX'
                def remotePassword = 'XXXX'

                // Start the Windows service on the remote server
                sshCommand(
                    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(DescribableModel.java:492) at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:429) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:331) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:269) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)

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.