<# ---------------------------------------------------------------------------- # Version: # Created by: # Created on: # Updated on: # Script Function: ---------------------------------------------------------------------------- #> <# edit below this line! #> $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" } }