Install PowerShell Module

How To – Install a PowerShell Module

As I like to work with PowerShell modules instead of a collection of scripts, I decided to put this article up. It’s kind of a reference article for myself to not have to explain the needed steps to install a PowerShell module in various articles. Let’s begin…

Basically there are two ways to install a PowerShell module:

  1. Install a module for PowerShell lower than version 5
  2. Install a module for PowerShell greater or equal version 5

Find your PowerShell version

To find out what version you have installed use

2016-04-13 16_25_04-Clipboard

The column “Major” is the one you’re looking for. So in my example it’s version 5.

PowerShell lower than version 5

In case you have an older version than 5 of PowerShell the easiest step would be to update to version 5 and just head over to the next paragraph. Really, you should! There are so many nice things added to version 5 – you don’t want to miss them. However, if you can’t update, here are the needed steps.

The environment variable $env:PSModulePath  tells you the locations where modules can be placed on your system. Most likely you get back something like this:

The first path is a location in your profile. If you share the system with some other people and they should not use your modules or you don’t have admin rights, place your module there. The second path (C:\Program Files) is where you place system wide modules. The third path (C:\Windows) is legacy and should not be used.

Create a folder with the of name of the module in one of the three locations. Copy the module files into that folder. Open a PowerShell and type

PowerShell greater or equal version 5

You rock! It’s so easy for you because you have the ability to use the PowerShell Gallery http://www.powershellgallery.com. It’s a central location where you can upload and download modules and scripts. It’s built into PowerShell version 5. If you just want to inspect a module and its files enter

Let’s install a module! If you share the system with some other people and they should not use your modules or you don’t have admin rights use the current user scope:

If the module should be installed for the system enter:

Of course not all modules are maintained in the PowerShell Gallery. In that case you have to use the legacy way for PowerShell lower than version 5.

Leave a Reply

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