Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     write-host "Import all CSVs from $($csvlocation) and start multi-job copy for each CSV."
  2.     $csvs = gci -Path $csvlocation *.csv
  3.     foreach ($csv in $csvs) {
  4.         $sourcecsv = import-csv $csv.FullName
  5.         Start-Job -ArgumentList $sourcecsv -scriptblock {
  6.             param($sourcecsv)
  7.             foreach ($item in $sourcecsv){
  8.             try {
  9.                 Test-Path $item.Destination
  10.             } catch {
  11.                 write-host "$($item.Destination) not accessiable, moving on to next item."
  12.                 Continue
  13.             }  
  14.                 $date = (Get-Date).tostring("yyyyMMdd")
  15.                 $name = $item.FullName.Split("\\")[2]
  16.                 emcopy64 $item.FullName $item.Destination /s /o /c /r:3 /w:5 /q /log+:C:\evt\log\$name'_'$date.log
  17.             }
  18.         }
  19.     }
  20.     Return
  21.     }
  22.  
  23. CSV items look like this:
  24.  
  25. Name    FullName    Destination
  26. dir1    C:\sharesource1\dir1    C:\Destination1\
  27. dir2    C:\sharesource1\dir2    C:\Destination1\
  28. dir3    C:\sharesource1\dir3    C:\Destination1\
  29. dir4    C:\sharesource2\dir4    C:\Destination2\
  30. dir5    C:\sharesource3\dir5    C:\Destination3\
  31. dir6    C:\sharesource3\dir6    C:\Destination3\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement