SQL agent job failing with cannot open service control manager

Dear Experts,

I am able to run get-services from powershell command window/ise but when I schedule the same script in SQL agent job and execute, it is failing with cannot open service control manager.

Can anyone share your experience on this. Am I missing something?




No Data
  • Hi Brahma,


    A couple of questions:


    1. When you are executing the script are you on the SQL box or on your domain pc?


    2. From your domain PC RIGHT CLICK on powershell and open the ISE console as an administrator.


    3. Verify that you have permission to that SQL BOX. 

    - put your AD usernamein the POWER USER GROUP

    - put your AD username in the Remote Desktop GROUP

    - verify that you can run scripts against that SQL BOX


    4. What is the error that you are getting?


    5. Can you log into that SQL box using your AD credentials?


    6. I would rewrite the command like so:

    get-services -comp nascest | ?{$_.name -like "*SQL*"}


    invoke-command -comp nascest -scriptblock {get-services | ?{$_.name -like "*SQL*"}}


    Advise and let us know.




No Data