2005 agent job - powershell job step

  • Hi All,

    I'm a newbie with powershell so i apologise if i'm making any really basic mistakes here or if my explanation is too vague.

    I'm trying to code an agent job to execute a powershell script which returns details of drive space available on my servers but i am using an SQL Server 2005 instance.

    There is no "powershell" option in the type drop down menu so is this not possible?

    Regards,

    Jodie.

  • If powershell is installed on the server, just create a cmdexec step and in the command box just type the following:

    "c:\windows\system32\windows powershell\v1.0\powershell.exe" -file <file>

    Where <file> is the location/name of your script file. Also "c:\windows\system32" is just a generalization, so just ensure that path is correct for you before running the job.

    Joie Andrew
    "Since 1982"

  • great, thanks for the advice. i'll give it a try and let you know how i get on.

  • Something I just forgot. Make sure that the powershell environment is setup to run scripts. By default scripts are disabled in powershell. You need to make sure that the execution policy is setup correctly to run scripts. This is done with the set-executionpolicy cmdlet. Check out about_execution_policies for more info.

    Joie Andrew
    "Since 1982"

  • When i have this in the command box:

    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -file h:\failedsqljobs_email.ps1

    i end up getting an error of:

    The term '-f' is not recognized as a cmdlet, function, operable program, or scr ipt file. Verify the term and try again. At line:1 char:3 + -fi <<<< le h:\failedsqljobs_email.ps1. Process Exit Code 1. The step failed.

    ????

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

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