Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $computerlist="computer01","computer02","computer03","computer04","computer05","computer06","computer07","computer08","computer09","computer10","computer11","computer12","computer13","computer14","computer15" #list of computer names that need fixing
- $sourcedir="C:\fixess\data"
- $targetdir="c$\Program Files (x86)\Common Files\Government\Program\201207030908"
- $count=0 #counting the number of loops for no useful reason
- $wait=60 #how many seconds to wait between runs
- Write-host "$(Get-Date) Script started"
- While($true)
- {
- foreach ($computer in $computerlist)
- {
- #if the computer is on and the directory doesn't exist, silently copy the files over
- if ((test-path "\\$computer\c$") -and -not (test-path "\\$computer\$targetdir"))
- {
- robocopy "$sourcedir" "\\$computer\$targetdir" /MIR /E /R:0 /W:1 /NJH /NJS /NDL /NC /NS /NP /NFL /A-:SH
- Write-host "$(Get-Date) Fixed: $computer on pass $count"
- }
- }
- $count++
- #Every 20 loops, post an update just so I know it's still running
- if ($count%20 -eq 0) { Write-host "$(Get-Date) Don't worry, the script is still running" }
- #Have a break before running the script again.
- Start-Sleep -s $wait
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement