• I don't think I explained my problem very well - plus I have now answered it myself. To clarify, my problem was that I have the name of a SSIS package which I have found by looking at the sysjobsteps table. I need to use Powershell copy-item to copy that package file to a remote server for disaster recovery. I was trying to use the drive letter as a variable but it turns out that is not necessary.

    In other words, I need to tranform this:

    FILE "C:\Projects\FakeJob.dtsx" /CHECKPOINTING OFF /REPORTING E

    To this:

    \\server1\C$\Projects\FakeJob.dtsx /CHECKPOINTING OFF /REPORTING E

    After further research, I found that most people do these complicated replace functions in increments. Although it is probably possible to do the transformation in one giant statement, I got the results I needed with this routine:

    $Server = 'server1'

    $job ='FILE "C:\Projects\FakeJob.dtsx" /CHECKPOINTING OFF /REPORTING E'

    $UNCPath =$job -replace (":", "$") # replace the ":" with a "$"

    $UNCPath =$UNCPath -replace "File","" # get rid of the word 'File'

    $UNCPath =$UNCPath -replace ' "','' # get rid of extra quotation marks and space before the file letter

    $UNCPath= $UNCPath -replace 'dtsx"','dtsx' # get rid of the extra quotation marks around 'dtsx'

    $UNCPath =$UNCPath.Insert(0, "\\"+ $Server + "\") # adds \\$server

    $UNCPath

    The script is working now and I don't have to worry that somebody will put an SSIS script in an unusual location. As long as it's set up as a job, I should now be able to find it and copy the file.