How to Install Software on Remote Computers With PowerShell Script

Does anyone happen to know how to install Software on Remote Machines using a PowerShell script?

If you have an example script it would be awesome.

Invoke-Command is used to run PowerShell commands on a remote computer.

Start-Process will execute the installer for the software you are trying to install. For this you need the command line installation parameters, usually something like this: Start-Process -Wait -Verb RunAs -FilePath msiexec.exe -ArgumentList “installer.msi /i /qn /norestart”

If you already have the file on the remote system, we can run it with Invoke-Command.

Invoke-Command -ComputerName server01 -ScriptBlock {
c:\software\installer.exe /silent
}
There are two important details to be aware of right away.

The first detail is that you need to maintain a remote session while the installer is running. If the installer does not block execution (it returns control back to the shell while it executes), your script may finish before the installer finishes. This will cancel the install as it closes the remote session.

You will need to call Start-Process -Wait if you are having that issue.

Invoke-Command -ComputerName server01 -ScriptBlock {
Start-Process c:\windows\temp\installer.exe -ArgumentList ‘/silent’ -Wait
}

I hope this information will be helpful!

Ben Martin

Hi Ben,

This information is most helpful. I do have a question about this and the entire process for that matter.

Do each of the remote target machines need to have PSRemoting enabled for this to work?

 

Thanks,

Orlando

Hi Orlando,

I doubt you’ll get a reply from that user. I have reported all the account’s replies but they haven’t been removed yet; it’s just copying and pasting content from blogs that appears to be semi-relevant to the questions being asked, probably in an effort to get some ‘reputation’ so it can continue to spam the link it included in at least one other post.

If you found its comment useful, here is the full blog article that it stole the content from:

https://powershellexplained.com/2017-04-22-Powershell-installing-remote-software/