This article tells you how to install the Azure PowerShell modules using PowerShellGet. These instructions work on Windows, macOS, and Linux platforms. For the Az module, currently no other installation methods are supported.
Requirements
Azure PowerShell works with PowerShell 5.1 or higher on Windows, or PowerShell 6 on any platform. To check your PowerShell version, run the command:
$PSVersionTable.PSVersion
If you have an outdated version or need to install PowerShell, see Installing various versions of PowerShell. Install information for your platform is linked from that page.
If you are using PowerShell 5 on Windows, you also need .NET Framework 4.7.2 installed. For instructions on updating or installing a new version of .NET Framework, see the .NET Framework installation guide.
Install the Azure PowerShell module
Important
You can have both the AzureRM and Az modules installed at the same time. If you have both modules installed, don’t enable aliases. Enabling aliases will cause conflicts between AzureRM cmdlets and Az command aliases, and could cause unexpected behavior. It’s recommended that before installing the Az module, you uninstall AzureRM. You can always uninstall AzureRM or enable aliases at any time. To learn about the AzureRM command aliases, see Migrate from AzureRM to Az. For uninstall instructions, see Uninstall the AzureRM module.
To install modules at a global scope, you need elevated privileges to install modules from the PowerShell Gallery. To install Azure PowerShell, run the following command in an elevated session (“Run as Administrator” on Windows, or with superuser privileges on macOS or Linux):
Install-Module -Name Az -AllowClobber
If you don’t have access to administrator privileges, you can install for the current user by adding the -Scope
argument.
Install-Module -Name Az -AllowClobber -Scope CurrentUser
By default, the PowerShell gallery isn’t configured as a trusted repository for PowerShellGet. The first time you use the PSGallery you see the following prompt:
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"):
Answer Yes
or Yes to All
to continue with the installation.
The Az module is a rollup module for the Azure PowerShell cmdlets. Installing it downloads all of the available Azure Resource Manager modules, and makes their cmdlets available for use.
Source: Install Azure PowerShell with PowerShellGet | Microsoft Docs
———————————————————————————-
Fix the execution policy by this simple command:
PS c:\> Set-ExecutionPolicy RemoteSigned
If you are on PowerShell Window then it will throw a popup to confirm to change the Execution policy, you can choose “Yes”:
Sign in
To start working with Azure PowerShell, sign in with your Azure credentials.
# Connect to Azure with a browser sign in token
Connect-AzAccount
Note
If you’ve disabled module autoloading, you need to manually import the module with Import-Module Az
. Because of the way the module is structured, this can take a few seconds.
You’ll need to repeat these steps for every new PowerShell session you start. To learn how to persist your Azure sign-in across PowerShell sessions, see Persist user credentials across PowerShell sessions.