The built-in PowerShell Package Manager is unreliable when it comes to installing and removing software packages in the MSI format. However, there is an excellent open source Windows Installer PowerShell module provided by Heath Stewart for performing many tasks with MSI installers and MSI-based installations.

Micah Rairdon

I am a PowerShell fanatic currently working in Windows client management at Haworth based out of Holland, MI. I tinker around and document my findings at tiberriver256.github.io and you can find me on Twitter @tiberriver256.

You can install the module from the PowerShell Gallery using the following command:

Installing MSIs ^

While you can use the standard msiexec command line for installing your MSIs, the command below is built with PowerShell in mind. This means it always executes silently and returns progress, warnings, and errors directly to the PowerShell pipeline.

The same features apply to the other cmdlets provided for modifying or removing existing installations: Install-MSIPatch, Repair-MSIProduct, Uninstall-MSIPatch, and Uninstall-MSIProduct.

Getting information ^

Sometimes you have to get information from the MSI file without installing the program. You can easily accomplish this using the following command:

If we run this against an MSI for installing the Microsoft Deployment Toolkit (MDT), we get the following results:

Information displayed from the Get MSIProperty command

Information displayed from the Get MSIProperty command

Get-MSIProductInfo easily retrieves information on existing installations:

The above example will show us all the installations with a product name matching SharePoint.

Results from the Get MSIProductInfo command

Results from the Get MSIProductInfo command

Uninstalling MSIs ^

We can also pipe the results of this command to other commands so we can modify existing installations.

The above example removes all installed products on the PC that have a product name matching SharePoint.

Generating DSC configurations ^

A simple use case example is generating a DSC configuration. Let's say you need to script a configuration for servers using the Microsoft Desired State Configuration Package resource. The documentation specifies that we have three required parameters: Name (package name), Path (location of the package), and ProductId (unique identifier).

The ProductId and the Name both need to come from the MSI for the DSC to work properly. Depending on the number of MSIs you have, this could quickly become a pain. Using the MSI module though, we can quickly loop through all the MSIs in a directory and automatically create our configuration. We're using code to write our code!

Running this simple script in a directory with a couple of MDT MSIs yields the following configuration script ready for copying and pasting into an existing configuration:

Win the monthly 4sysops member prize for IT pros

Share
2+

Users who have LIKED this post:

  • avatar
  • avatar

Related Posts

2 Comments
  1. Leos Marek 5 months ago

    Hi Micah,

    is it possible to use this remotely with invoke-command or enter-pssession?

    In case yes does this support msi to be located on unc share? Is it able possible to do such installation over slow wan? (1mbps)

    thanks L

    1+

    Users who have LIKED this comment:

    • avatar
    • Author
      Micah Rairdon 5 months ago

      Hi Leos,

      As long as the module is installed on the remote PCs I would expect it to work as expected with PSRemoting.

      It would work with MSIs from a UNC share but of course I would not recommend using it over a slow internet connection like you had mentioned. I would not expect to see any network performance benefits when downloading files over UNC over using something like msiexec.

      That being said, the author of the module might be able to answer your question more directly and I am sure he would appreciate you filing an issue on Github if you do find any bugs with the software or have any feature requests.

      https://github.com/heaths/psmsi

      0

Leave a reply

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

*

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2017

Log in with your credentials

or    

Forgot your details?

Create Account