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
精彩评论