How to Install Azure PowerShell (Oct 2016)

Installing and getting the Azure PowerShell modules working can be extremely frustrating.  Below I will attempt to streamline the process.  I created this process for Windows Server 2012 R2, however the same steps may work on other versions of Windows Server.

  1. Check your current version of PowerShell:
    Enter the following in PowerShell: $PSVersionTable.PSVersion
    check that you are on version 5 by looking at the ‘major version’ column.
    powershell-version-5
    If you are not on PowerShell 5.0 then you need to install Windows Management Framework 5.0 which contains PowerShell 5.0: https://www.microsoft.com/en-us/download/details.aspx?id=50395
    Note: For Windows 2012 R2, select to download the file for Windows 8.1 x64 otherwise you will get an error that “The update is not applicable to your computer”.
    Note: Optionally google Windows Management Framework 5.1 to see if it’s download is available yet (WMF 5.1 preview is out at the time of this writing)
    Note: WMF 5.0 requires .Net FrameWork 4.5 (seems to be present by default on server 2012 R2 on Azure, generally installed through programs and features).

2. Import the PowerShellGet Module which will be used to install Azure PowerShell:

Enter the following command from PowerShell:
Import-Module -Name PowerShellGet (this has the install-module function)
Troubleshooting: if the command fails, confirm the presence of PowerShellGet, check if you have the folder: C:\Program Files\WindowsPowerShell\Modules\PowerShellGet

OPTIONAL: Check add/remove programs to see if you have Microsoft Web Platform Installer 5.0 Installed.  If you do not, or you have an old version, then download and install Web Platform Installer 5.0.  Note: I choose not to install Web Platform Installer.

Skip to step 5, importing modules, to see if you can now import the powershell modules, if not, then perform step 4 to install the modules.

4. To install Azure PowerShell 1.0.1 or newer with PowerShellGet, run the following commands:

Note: Installing Azure PowerShell 1.0.1 or newer using PowerShellGet requires Windows Management Framework 5.0 (Windows 10 includes this by default).

# Install the Azure Resource Manager modules from PowerShell Gallery
Install-Module AzureRM
Install-AzureRM

# Install the Azure Service Management module from PowerShell Gallery
Install-Module Azure

5. Now that Azure PowerShell 1.x has been installed, you can import the Azure and AzureRM modules. Azure Resource Manager is split into component modules. For example, Azure Resource Management modules for compute services are in module AzureRM.Compute.

# Import all of the AzureRM.* modules within the known semantic version range
Import-AzureRM (command doesn’t work and I believe has been deprecated.  Instead use: Import-Module AzureRM)

# Import Azure Service Management
Import-Module Azure

Resources:

https://azure.microsoft.com/en-us/blog/azps-1-0-pre/

Related

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.