How to install the specific version of the PowerShell module version?

PowerShellMicrosoft TechnologiesSoftware & Coding

To install the specific version of the PowerShell module, we need to use the -RequiredVersion parameter with the Install-Module command.

To find which module versions are available, we can use the Find-Module command with the -AllVersions parameter which retrieves all the versions of the module available in the PSGallery.

In this example, we will use the 7Zip4PowerShell module.


Find-Module 7zip4PowerShell -AllVersions | ft -AutoSize

When you run this command, you can see there are multiple versions available for this module.


Version  Name            Repository
-------  ----            ----------
1.13.0   7Zip4Powershell PSGallery
1.12.0   7Zip4Powershell PSGallery
1.11.0   7Zip4Powershell PSGallery 7Zip4Powershell PSGallery
1.9.0    7Zip4Powershell PSGallery
1.8.0    7Zip4Powershell PSGallery
1.7.1    7Zip4Powershell PSGallery

We need to install here version 1.9.0 for all the users, so we will use the below command.


Install-Module 7Zip4PowerShell -RequiredVersion 1.8.0 -Scope AllUsers -Force -Verbose

To install PowerShell module on the remote server, use the below command,


Invoke-Command -ComputerName RemoteMachine1 -ScriptBlock {Install-Module 7Zip4PowerShell -RequiredVersion 1.8.0 -Scope AllUsers -Force -Verbose}
Published on 18-Mar-2021 07:49:02