PowerShell Job Agent does not work?

  • What am I doing wrong?

    As a step in a Job I am trying to overwrite file by copying the drive is mapped, but I used unc path just in case.

    In PowerShell this works in the command line interface.

    Copy \\V240\folder\foo.txt \\V240\folder\bar.txt

    When I put it in a Job Agent in SQL Server with the PowerShell option it says successfully completed but the file is not being copied.

  • Maybe security context ?

    Wen you run a Powershell sql agent job, the security context is the SQL Server Account (if the job owner is SA)..so take a look if the sql agent account have privlegies to copy the file to this folder.

    $hell your Experience !!![/url]

  • Copy is a Windows CmdShell command. Try using the Copy-Item PowerShell CmdLet and set the -ErrorAction set to Stop

    Copy-Item -Path \\V240\folder\foo.txt -Destination \\V240\folder\bar.txt -ErrorAction Stop

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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