icecurtain
icecurtain

Reputation: 675

PowerShell Copy on a mapped or UNC Drive (SQL Server Job Agent)

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 am using unc path just in case.

In PowerShell this works in the command line interface.

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

1

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

Upvotes: 1

Views: 2361

Answers (1)

Chad Miller
Chad Miller

Reputation: 41767

The Powershell SQL Agent job step starts Powershell sqlps host in the SQL Server provider. I would try setting location (cd) to the filesystem provider before copying

set-location c:\
Copy \V240\folder\foo.txt \V240\folder\bar.txt

Upvotes: 1

Related Questions