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?

 

Thanks

Brahma

Parents
No Data
Reply
  • Hi Brahma,

     

    A couple of questions:

     

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

    I tried both. Once sql box and once on my domain PC.

     

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

    Yes, I am running like this only.

    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

     I am in local admin group

    4. What is the error that you are getting?

     cannot open service control manager

     

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

    Yes

     

    6. I would rewrite the command like so:

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

    OR

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

     Tried no luck

     

     

Children
No Data