Error when configuring SQL job step to execute powershell script

  • I'm trying to create a SQL-job step that will be executing a powershell script.

    In the Job Step Properties page:

    Under Type I choose "Powershell".

    Under Run as I have: "SQL Server Agent Service Account".

    I then click the "Open" button and navigate to the location of the powershell script (local on the server).

    I get this error when I pick the script file and click OK:

    Access to the path '...\script.ps1' is denied. (mscorlib)

    The SQL Agent account is local admin on the server, so there should be no access issues.

    When I RDP to the server using that account, I can navigate to the script location without any problems.

    Anyone seen this before? It's not making any sense...

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]

  • Do you get an error if you set it up as a CmdExec jobstep that executes

    powershell c:\myfilepath\script.ps1

    Well, obviouslyyou won't get an error while creating the job step in this scenario, but when you run it I mean!

    ------------------------------------------------------------------------
    Bite-sized fiction (with added teeth) [/url]

  • It turned out the ps1 file was readonly; as soon as I made it read-write, issue was fixed.

    Silly eh? 🙂

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]

  • Ah, they're the best kind of issues 🙂

    ------------------------------------------------------------------------
    Bite-sized fiction (with added teeth) [/url]

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

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