Last active
August 29, 2015 14:20
-
-
Save mercdev/4c4e57ed1ec97a51476f to your computer and use it in GitHub Desktop.
Multithreaded file copy (via Robocopy) to multiple destinations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
$source = "\\sourcefiles\path\here"; | |
$auth = "\\authserver\c$\Fileroot"; | |
$destDev = "\\devserver\C$\FileRoot"; | |
$destTest = "\\testserver\C$\FileRoot"; | |
$destStage = "\\stageserver\C$\FileRoot"; | |
$destProd = "\\productionserver\C$\FileRoot"; | |
#$scriptBlock = { Param($source,$destination) robocopy $source $destination /MAXAGE:21 /MT:32 /S /NC /NS /NDL /NJH /NJS /NFL } | |
$scriptBlock = { Param($source,$destination) robocopy $source $destination /MAXAGE:21 /MT:32 /S } | |
$destDev, $destTest, $destStage, $destProd | ForEach-Object { Start-Job -ScriptBlock $scriptBlock -ArgumentList $auth,$_ } | |
while (Get-Job -State "Running") { Start-Sleep 5; } | |
Get-Job | Receive-Job | |
Remove-Job * | |
"Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment