Skip to content

Instantly share code, notes, and snippets.

@joegasper
Created December 1, 2017 20:24
Show Gist options
  • Save joegasper/7390950f39bffb8d08946282c8a1c2d3 to your computer and use it in GitHub Desktop.
Save joegasper/7390950f39bffb8d08946282c8a1c2d3 to your computer and use it in GitHub Desktop.
Run Robocopy with PowerShell
$site = 'mysite01'
$source = "\\my-web1\e$\websites\$site\"
$destination = "E:\websites\$site\"
#List only first
$logfile = "E:\$site-robo-test.txt"
$switches = "/E /L /R:2 /W:3 /NP /FFT /DST /LOG:$logfile /XF "".DS_Store"" ""thumbs.db"""
& robocopy.exe $source $destination $switches.Split(' ')
#Check Log File
Get-Content -Path $logfile -First 17
Get-Content -Path $logfile -Tail 10
#Run for real
$logfile = "E:\$site-robo.txt"
$switches = "/E /R:2 /W:3 /NP /FFT /DST /LOG:$logfile /XF "".DS_Store"" ""thumbs.db"""
& robocopy.exe $source $destination $switches.Split(' ')
#Check Log File
Get-Content -Path $logfile -First 17
Get-Content -Path $logfile -Tail 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment