SHARE
TWEET

Untitled

a guest Jul 25th, 2012 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $computerlist="computer01","computer02","computer03","computer04","computer05","computer06","computer07","computer08","computer09","computer10","computer11","computer12","computer13","computer14","computer15" #list of computer names that need fixing
  2. $sourcedir="C:\fixess\data"
  3. $targetdir="c$\Program Files (x86)\Common Files\Government\Program\201207030908"
  4. $count=0 #counting the number of loops for no useful reason
  5. $wait=60 #how many seconds to wait between runs
  6.  
  7. Write-host "$(Get-Date) Script started"
  8.  
  9. While($true)
  10. {
  11.    foreach ($computer in $computerlist)
  12.    {
  13.       #if the computer is on and the directory doesn't exist, silently copy the files over
  14.       if ((test-path "\\$computer\c$") -and -not (test-path "\\$computer\$targetdir"))
  15.       {
  16.          robocopy "$sourcedir" "\\$computer\$targetdir" /MIR /E /R:0 /W:1 /NJH /NJS /NDL /NC /NS /NP /NFL /A-:SH
  17.          Write-host "$(Get-Date) Fixed: $computer on pass $count"
  18.       }
  19.    }
  20.    $count++
  21.    
  22.    #Every 20 loops, post an update just so I know it's still running
  23.    if ($count%20 -eq 0) { Write-host "$(Get-Date) Don't worry, the script is still running" }
  24.    
  25.    #Have a break before running the script again.
  26.    Start-Sleep -s $wait
  27.    
  28. }
RAW Paste Data
Top