开发者

Not able to start and stop service from remote machine

We have some winodow services on the remote machine. I am not able to start and stop that services usin开发者_开发知识库g service controller from my machine.


You can use Powershell and supply it with the appropriate credentials:

PS C:\Users\YourUserName>$remoteComp = "remoteComputerName"
PS C:\Users\YourUserName>$svc = "Service Name"
PS C:\Users\YourUserName>$c = Get-Credential
PS C:\Users\YourUserName>$obj = (gwmi -computername $comp -class Win32_Service -computer $remoteComp -Credential $c | Where-Object { $_.Name -match "^$svc*" }

Now you can use $obj to stop and start the service

PS C:\Users\YourUserName>$obj.StopService()
PS C:\Users\YourUserName>$obj.StartService()

In addition, if you want to see the methods and properties available for $obj use this command:

PS C:\Users\YourUserName>$obj | Get-Member
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜