Software Installation on Multiple Servers
Posted by Superadmin on January 28 2023 15:57:44

Software Installation on Multiple Servers

 

 

 

$servers = gc C:\provide path
$source = "\\source_server\Treesize" ### share the folder in which the installation file is present ##
$tempath ="\\source_server\Treesize"
$destination = "c$"
foreach ($server in $servers) 
{
$session = New-PSSession -ComputerName $server
if(test-connection -Cn $server -quiet){
Copy-Item $source -Destination \\$server\$destination -Recurse -Force
if(Test-Path -path $tempath){  
Invoke-command -session $session -ScriptBlock {C:\treesize\TreeSizeFreeSetup.exe /uninst /silent /restart}
Write-Host -ForeGroundColor Green "Installation successful on $server"
  }  
  }
  else
  {
    Write-Host -ForeGroundColor red "Installation failed on $server"
 }
 }