Powershell with Robocopy and Arguments Passing

后端 未结 4 821
粉色の甜心
粉色の甜心 2021-01-02 04:09

I\'m trying to write a script that uses robocopy. If I were just doing this manually, my command would be:

robocopy c:\\hold\\test1 c:\\hold\\t         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 04:30

    Putting the options in separate arguments worked for me. Using Robocopy for copying excluding any CSV files.

    $roboCopyPath = $env:ROBOCOPY_PATH
    $otherLogsPath = [System.IO.Path]::Combine($basePath, "Logs-Other")
    $atrTestResults = [System.IO.Path]::Combine($Release, $BuildNumber)
    $ResultsSummary = [System.IO.Path]::Combine($basePath, "Result")
    
    $robocopyOptions = @("/log:$otherLogsPath\robocopy.log", '/xf', '*.csv')
    $CmdLine = @($atrTestResults, $ResultsSummary) + $robocopyOptions 
    &$roboCopyPath $CmdLine
    

提交回复
热议问题