How to Install an Application on a Remote Machine Using PowerShell

January 16, 2008

Although this seems as it would be a common tasks for administrators and developers alike, I found very little documentation on the Internet on how to install an msi or exe on a remote machine using PowerShell. I even found comments saying it couldn’t be done at all! Bull Hugly, it can be done! I have provided two pieces of code that you can use to install either an msi package or exe on a remote server using PowerShell.

Installing an MSI

Using a short hand of WMI in PowerShell , you can execute the following code to install your msi package:

$box=”deviis01” #this is the name of your server

$product= [WMICLASS]”\\$box\ROOT\CIMV2:win32_Product”

Write-Host “Installing software on $box”


$product.Install(“c:\Setup \somesoftwarepackage.msi”)

The best part is it will install it silently so you don’t have to worry about command arguments to do that.

Installing an EXE

The exe was more of a pain and I wasn’t able to get it to work with the Install method. If someone else is able to get it to work, please post a comment to share with the rest of us because I would like to know if it is possible, however, here is what you can do to install your exe.

$box=”deviis01” #this is the name of your server

Write-Host “Installing software on $box”

([WMICLASS]”\\$box\ROOT\CIMV2:win32_process”).Create(“cmd.exe /c c:\Setup\somesoftware.exe /s /v`” /qn”)

This actually works by creating a new process on the remote server, calling the cmd.exe and passing it the arguments for installing your program. One thing to make note of is all the command switches I have at the end. You will want to check your exe to see what switches it takes; for example mine above is using an exe created with InstallShield so the command line options might be different, so just keep that in mind.

-Flea#