Code issue

  • A job step received an error at line 33 in a PowerShell script. The corresponding line is 'Get-WmiObject -ComputerName $serverName -query " '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) '. Process Exit Code -1. The step failed.

    The code works in Powershell ISE but when scheduled as a SQLJob it fails. Is this a permissions issue ? If yes, how to fix it.If not please advise.

    Thanks

     

    • Does the sqlagent service account have the authority to perform the wmi query?
    • Does the sqlagent job step proxy account have the needed authority to perform the wmi query ?

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Thanks for the response..

    how do we check what you recommended ?

    https://www.sqlservercentral.com/blogs/quick-tip-wmi-alerts-and-sql-server-agent-permissions..

    Let me check and get back...

    But the query captures data from 100+servers...so how does this work...check on all servers or ....

    • This reply was modified 9 months, 2 weeks ago by  mtz676.
  • mtz676 wrote:

    Thanks for the response..

    how do we check what you recommended ?

    https://www.sqlservercentral.com/blogs/quick-tip-wmi-alerts-and-sql-server-agent-permissions..

    Let me check and get back...

    But the query captures data from 100+servers...so how does this work...check on all servers or ....

    Check the account which is running the SQL Agent service on the SQL Server. Unless you have configured a proxy account for the job, that will be the account which is running the PoSh script.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Hello Phil, Did as advised. Not working.same error

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply