It's a long story, but I need to create a SQL trigger that executes a script remotely which executes another script remotely (yeah, I know). I'm using PowerShell.
I have started at the end:
Get-Service –Name “service” –ComputerName “Server2” | Set-service –Status Stopped
Get-Service –Name “service” –ComputerName “Server2” | Set-service –Status Running
This works just fine. Then, the script that will be executed on the trigger:
Invoke-Command –computername “cluster” –command {d:\adminscripts\RestartServer2Service.ps1}
(yes, I use a NLB cluster, and it's reading the script)
But, I get this:
Cannot find any service with service name ‘service’.
Any thoughts? Any help will be appreciated. Thanks