Aller au contenu

PHP : Application de déploiement de fichier sur windows

<?php

$servers = array(
  "server1" => "192.168.1.100",
  "server2" => "192.168.1.101",
  "server3" => "192.168.1.102"
);

$src_folder = "C:\\source\\";
$dst_folder = "C:\\destination\\";

// Connect to each server and transfer files
foreach ($servers as $server) {
  // Connect to server using Windows Remote Management (WinRM)
  $connection = new \WinRM\WinRMClient($server, [
    "transport" => "ssl",
    "port" => 5986,
    "user" => "username",
    "pass" => "password",
    "remote_shell_id" => "Microsoft.PowerShell"
  ]);

  // Copy files from source folder to destination folder
  $connection->runCommand("Copy-Item -Path '$src_folder' -Destination '$dst_folder' -Recurse");

  // Close connection to server
  $connection->close();
}

echo "Files deployed successfully to all servers.";

?>

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *