Category Archives: Powershell

Remote install an msi with Powershell

Remote install an msi with Powershell?

I know I have had to do this many times but there are many pitfalls to be wary of. Here is the simplest method to get that pesky msi to install now on a remote computer with Powershell.

Problem

You are on your admin workstation and you want to install an msi which I will call ‘installer.msi’ on at least one machine in your domain. Installer.msi is located on a file server on the network.

Solution

A Powershell script that copies the file to the local machine, installs the msi then deletes installer.msi from the local machine. How do you do this, simple.

copy-item copy-item -Path \\fileserver\share\installer.msi -Destination \\machine-to-instal-to\c$\temp\installer.msi
Invoke-WmiMethod -Path Win32_Product -Name Install -ComputerName "machine-to-install-to" -ArgumentList @($true,$null,"\\machine-to-install-to\c$\installer.msi")
remove-item -path  \\machine-to-instal-to\c$\temp\installer.msi

I have found this is the simplest method. Obviously you should consider wrapping this in a try catch and putting it in a loop to install on a set of computers.

I have had some success with using invoke-command calling start-process and this is probably the best method if you want to install an exe rather than an msi.

Why

Why not use a GPO I hear you shout? Simple. GPO’s do not offer the flexibility. I use this when I want to install it now, not when the computer next reboots, or if I want to do some pre/post processing like copying a config file around. You may need to use a similar method if you have a badly written service that doesn’t stop for the installer.

PowerShell 3.0 jumpstart

I was once in doubt about Microsofts attempt to replicate the all powerful *nix command line with PowerShell but my eyes were opened and I got on the bandwagon. Now you will find me gathering information, solving problems and generally having a great time in PowerShell ISE. The lightbulb moment came when I took the PowerShell 3.0 Jumpstart course on Microsoft Virtual Academy.

It starts slow and steady. No prior PowerShell needed, however you do need to leave your preconceptions behind if you are coming from Bash, Bourne, Csh, Zsh, Dos or any other shell. The two presenters are legends Jeffrey Snover was the lead architect behind PowerShell and Jason Helmick is a long time Microsoft trainer and generally great guy.

What are you going to learn watching the PowerShell 3.0 jumpstart?

I learned alot, I could put powerhsell together before but I wouldn’t have said I understood what I was doing, After this I feel more confident in just typing out what I want and most of the time it works 🙂

PowerShell really does rock!