Running Powershell as SQL Server Agent task

  • Hi,

    with Powershell in Agent-Task:

    i want to check if a File in Folder exists, then goto next Step - else goto Failure.

    Is Powershell the best way to check this - or cmdExec - or SSIS ????

    (SQL2012, PSV3)

    Regards

    Nicole

    😉

  • SSIS seems to me overkill for just checking a file exists.

    Powershell can do that:

    $ErrorActionPreference = "Stop"

    if( -not (Test-Path "c:\temp\im_not_there.txt")) { throw "Not there!" }

    CMD can do that as well

    if not exist c:\temp\im_not_there.txt exit /b 1

    -- Gianluca Sartori

Viewing 2 posts - 1 through 2 (of 2 total)

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