Uncategorized

Remotely Install any application with Powershell

How to Remotely Install any application across a Server Cluster

 

After a few days of tinkering with Powershell, I was able to get this script to work smoothly on multiple Remote Servers within a Home-Lab environment.

 

  1. Create a notepad and add all of the server names one under the other: SERVERS.txt

Server01

Server02

Server03

  • Create a Shared Folder and set it as shared (this part is important since PS likes to run apps\msi from these type of folders, i had a lot of trouble when this wasn’t the case. \\dc01\software\AcrobatDC.exe
  • Run the script below, which will copy, create a temp folder, run the application, install it and remove the installer folder created initally.

 

 

$computers = Get-Content C:\Software\SERVERS.txt

$sourcefile = “\\dc01\software\AcrobatDC.exe

$username = Read-host “administrator:”$securestring = Read-Host -AsSecureString “Password:”

$domaincredentials = New-Object System.Management.Automation.PSCredential -ArgumentList ‘username’, $securestring

 

foreach ($computer in $computers){
$destinationfolder = “\\$computer\C$\temp\”

if (!(Test-Path -Path $destinationfolder -Credential $domaincredentials)){
New-Item $destinationfolder -Type Directory -Credential $domaincredentials
}

Copy-Item -Path $sourcefile -Destination $destinationfolder

Invoke-Command -cn $computer -ScriptBlock {Powershell.exe C:\temp\AcrobatDC.exe /sAll /msi /norestart ALLUSERS=1 EULA_ACCEPT=YES}

Remove-Item $destinationfolder -Force -Recurse

}

Leave a Reply

Your email address will not be published. Required fields are marked *