SteGriff

Blog

Next & Previous

Managing PowerShell Modules

At time of writing, there are three different PowerShell modules for Azure. They are Azure (classic) AzureRM, and Az, the new one.

You can have more than one installed (although warnings say that AzureRM and Az don’t play nicely together) and you can also have more than one version of each one installed! So, they can get a little unruly.

Here are some handy commands for staying on top of modules on your system. This article focuses on Azure, but the commands will work for any modules at all.

Install a module

Install-Module AzureRM

To install for all users (requires Admin PowerShell):

Install-Module AzureRM -Scope AllUsers

To install a specific version:

Install-Module AzureRM -RequiredVersion 6.13.1

Use a specific version

PowerShell has a concept of “importing” a module, like a Python import or C# using. When you’ve got multiple versions of a module installed, you can choose which one to pull into your current session:

Import-Module AzureRM -RequiredVersion 1.0.1

Find the versions of a module installed

This will print to screen a list of all the installed versions of the given module:

Get-InstalledModule AzureRM -AllVersions

List/search the cmdlets within a Module

What can a module do? Different versions may have different collection of commands/cmdlets. This will list them out:

Get-Command -Module AzureRM
Get-Command -Module Azure | ? {$_.Name -like '*Website*'}

(? is shorthand for Where-Object, and the expression after it is a lambda, see also PowerShell Comparison Operators on ss64)

Find where a module lives

A bit like Linux’s which command, this is handy for finding out the path of a module and whether it’s installed for one user or all users. Here’s the shorthand followed by the expanded command:

(gmo -l AzureRM).path
(Get-Module -ListAvailable AzureRM).path

Source: PowerTip: Find the Path to a PowerShell Module

That’s all I got; I hope it helps!