Before using PowerShellGet to download and install Azure PowerShell, you must first configure your PowerShell environment with an execution policy that allows scripts to run. Since the default execution policy for PowerShell is Restricted, you must change it by running the Set-ExecutionPolicy command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Running the Set-ExecutionPolicy command, to set the execution policy to RemoteSigned, is sufficient for installing Azure PowerShell from the PowerShell Gallery. You could also set your policy to Unrestricted, but that would further open you up to unsigned commands that could be malicious. As you can see in the following screenshot, PowerShell will prompt you to confirm that you wish to change the execution policy:
Once your execution policy is set to RemoteSigned, you can install the AzureRM PowerShell module by running the Install-Module command:
Install-Module -Name AzureRM -AllowClobber
Running the preceding command launches the process of connecting to the PowerShell Gallery and downloading the Azure PowerShell module. The AllowClobber switch ensures that you get the full and complete installation of AzureRM.
As you can see in the following screenshot, the PowerShell Gallery is not configured as a trusted repository for PowerShellGet (you'd think it would be trusted by default). As such, you are likely to see a warning about the repository not being trusted, and you will be prompted whether you are sure you want to download the module. It's safe to answer Yes, or Yes to all, when you see this prompt.
Selecting Yes allows the installation of Azure PowerShell to continue:
The installation of Azure PowerShell is generally painless. The AzureRM module that gets installed is a rollup module for the Azure Resource Manager cmdlets. Installing the AzureRM module also pulls down, from the PowerShell Gallery, any Azure PowerShell module not previously installed.