Quantcast
Viewing all articles
Browse latest Browse all 12963

How can i run a powershell scripts from SQL Agent for SQL 2008 R2

Hi All.

I am trying to run a powershell script which stops a service via SQL Agent, at the moment the scripts says that it completes however the service isnt being stopped, I know SQL 2008 R2 only has the powershell mini version or so. I am just thinking of a way to do this without invoking xp_cmdshell.

if (Get-Service "Service" -ErrorAction SilentlyContinue)
{
    get-service MsMpSvc | where {$_.status -eq 'running'} | stop-service -pass

}

I have also tried to save this onto a powershell file and then use CMDExec to try to run it, that hasnt worked either.

Any ideas ?


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>