• sgnewman (9/5/2012)


    You need to change the provider when the job runs. It's running under the sqlserver:/ provider. Just do a cd c: at the top of your script and it will now accept the unc path.

    Scott

    Nailed it! This is the only place I've been able to find on the whole internets that has the solution. This has been driving me crazy for days! I chose to use the newer PowerShell command "Set-Location c:" instead, which does the same thing.

    opc.three (9/13/2012)


    bwperrin (9/13/2012)


    "cd c:" works! Thanks!!

    What build are you on?

    I'm willing to bet it worked for the guy using SQL 2012. Our powershell scripts were all working perfectly fine running as SQL agent jobs in SQL 2008 R2. We upgraded to SQL 2012 and all of our powershell scripts that performed file copy or moves would fail with "invalid path". Scott knew exactly what is happening now in SQL 2012.

    Thanks Scott!