Install and configure Azure PowerShell

Step 1: Install PowerShellGet

Installing items from the PowerShell Gallery requires the PowerShellGet module. Make sure you have the appropriate version of PowerShellGet and other system requirements. Run the following command to see if you have PowerShellGet installed on your system.

PowerShellCopy

<span class="hljs-pscommand">Get-Module</span> PowerShellGet<span class="hljs-parameter"> -list</span> | <span class="hljs-pscommand">Select-Object</span> Name,Version,Path

You should see something similar to the following output:

OutputCopy

Name          Version Path
----          ------- ----
PowerShellGet 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1

If you do not have PowerShellGet installed, see the How to get PowerShellGet section of this article.

Note

Using PowerShellGet requires an Execution Policy that allows you to run scripts. For more information about PowerShell’s Execution Policy, see About Execution Policies.

Step 2: Install Azure PowerShell

Installing Azure PowerShell from the PowerShell Gallery requires elevated privileges. Run the following command from an elevated PowerShell session:

PowerShellCopy

<span class="hljs-comment"># Install the Azure Resource Manager modules from the PowerShell Gallery</span>
<span class="hljs-pscommand">Install-Module</span> AzureRM<span class="hljs-parameter"> -AllowClobber</span>

By default, the PowerShell gallery is not configured as a Trusted repository for PowerShellGet. The first time you use the PSGallery you see the following prompt:

OutputCopy

Untrusted repository

You are installing the modules from an untrusted repository. If you trust this repository, change
its InstallationPolicy value by running the Set-PSRepository cmdlet.

Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

Answer ‘Yes’ or ‘Yes to All’ to continue with the installation.

Note

If you have a version older than 2.8.5.201 of NuGet, you are prompted to download and install the latest version of NuGet.

The AzureRM module is a rollup module for the Azure Resource Manager cmdlets. When you install the AzureRM module, any Azure PowerShell module not previously installed is downloaded and from the PowerShell Gallery.

If you have a previous version of Azure PowerShell installed you may receive an error. To resolve this issue, see the Updating to a new version of Azure PowerShell section of this article.

Step 3: Load the AzureRM module

Once the module is installed, you need to load the module into your PowerShell session. You should do this in a normal (non-elevated) PowerShell session. Modules are loaded using the 

Import-Module

 cmdlet, as follows:

PowerShellCopy

<span class="hljs-pscommand">Import-Module</span> AzureRM

You May Also Like

About the Author: Phil

Leave a Reply

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