document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. param($FILE)
  2. $window = (Get-Host).UI.RawUI
  3. $window.WindowTitle = "ENI TORRENT DEPLOY"
  4. $DATA="C:\\DATA" # Dossier de destination, les fichiers seront téléchargés ici
  5. $TORRENT_C="C:\\torrent" # Dossier contenant les .torrent en destination (client)
  6. $TORRENT_S="TORRENT" #Dossier contenant les .torrents (serveur)
  7. $counter_cours=-1 #Compteur pour le nom du .torrent
  8. $counter_salles=-1 #Compteur pour le nom de la salle
  9. $TEMP="TEMP" #Dossier temporaire pour recevoir les fichiers et logs
  10. $LogTime = Get-Date -Format "dd-MM-yyyy_HH-mm-ss" # obtenir la date des le lancement pour LOG
  11. $log = 1 # 1 ou 0 pour gestion des logs ou non
  12. $BIN="BIN" #Dossier contenant les binaires
  13. $PC=Get-content TEMP\\computers.txt # affichage pour verifs
  14. #FONCTIONS
  15. function time{ #Obtenir l\'heure lors de l\'appel de la fonction (utilise pour les logs)
  16.     $global:time=Get-Date -Format "HH:mm:ss"
  17. }
  18. function clean { #ne pas afficher les messages d\'informations
  19.     Select-Object -Property * -ExcludeProperty *
  20. }
  21. ForEach ($PC in $PC)
  22. {
  23.     if (Test-Connection -ComputerName $PC -Quiet -Count 2) { #test connexion, si true alors on lance
  24.         write-host "Lancement sur $PC de $FILE ..." -foregroundcolor green
  25.         #LOG
  26.         if ($log) {
  27.             time
  28.             write-output "$time --> Lancement sur $PC de $FILE ..." >> TEMP\\LOG_$LogTime.txt
  29.             }
  30.         # Kill du processus utorrent
  31.         write-host "Kill du processus ..." -foregroundcolor green
  32.         taskkill.exe /S $PC /IM utorrent.exe /T /F | clean
  33.         # creation du repertoire DATA
  34.         write-host "Creation repertoire DATA ..." -foregroundcolor green
  35.         $d = [WMIClass]"\\\\$PC\\root\\cimv2:Win32_Process"
  36.         $d.Create("cmd.exe /c md $DATA") | clean
  37.         # creation du repertoire torrent
  38.         write-host "Creation repertoire TORRENT ..." -foregroundcolor green
  39.         $t = [WMIClass]"\\\\$PC\\root\\cimv2:Win32_Process"
  40.         $t.Create("cmd.exe /c md $TORRENT_C") | clean
  41.         # copie du .torrent dans rerpertoire torrent
  42.         write-host "Copie du .torrent ..." -foregroundcolor green
  43.         Copy-Item $TORRENT_S\\$FILE -Destination \\\\$PC\\C$\\torrent\\ -force
  44.         # lancement de utorrent et ajout auto du .torrent
  45.         write-host "Lancement de uTorrent ..." -foregroundcolor green
  46.         .$BIN\\psexec.exe -accepteula \\\\$PC -c -v -d -s -i $BIN\\uTorrent.exe /NOINSTALL /DIRECTORY "$DATA" "$TORRENT_C\\$FILE"
  47.         #/HIDE
  48.     }
  49.     else { #si test NOK, on affiche et on log eventuellement
  50.         write-host "Le $PC ne repond pas !" -foregroundcolor white -backgroundcolor red
  51.                 #LOG
  52.         if ($log) {
  53.             time
  54.             write-output "$time --> Le $PC ne repond pas !" >> TEMP\\LOG_$LogTime.txt
  55.             }
  56.     }
  57. }
');