Search code examples
powershellazure-information-protection

Installing multiple modules with minimumversion at once in PowerShell


i would like to know if it is possible to install multiple modules in PowerShell (which of course is) but with specifying a minimumversion number.

Let's assume we have two modules to install:

  1. AIPService version 1.0.0.5
  2. ExchangeOnlineManagement version 2.0.5

Is it possible to do it in one line?

I tried following:

Install-Module -Name AIPService, ExchangeOnlineManagement -MinimumVersion 1.0.0.5, 2.0.5

Thought that this would work due to the fact, that we are able to list multiple modules.


Solution

  • As the docs show, parameter -MinimumVersion specifies the minimum version of a single module to install.
    In your case, you need do add two separate lines for each module to install because you want a different version or use a loop and a Hashtable to install. Something like:

    $modules = @{
        AIPService               = '1.0.0.5'
        ExchangeOnlineManagement = '2.0.5'
    }
    
    $modules.GetEnumerator() | ForEach-Object {
        Install-Module -Name $_.Name -MinimumVersion $_.Value
    }