How to Install Azure PowerShell: Step-by-Step Guide for All Platforms
To install Azure PowerShell, open your PowerShell terminal and run the command Install-Module -Name Az -Repository PSGallery -Scope CurrentUser. This installs the official, cross-platform Az PowerShell module directly from the PowerShell Gallery. It works on W...
To install Azure PowerShell, open your PowerShell terminal and run the command Install-Module -Name Az -Repository PSGallery -Scope CurrentUser. This installs the official, cross-platform Az PowerShell module directly from the PowerShell Gallery. It works on Windows, macOS, and Linux, requiring PowerShell 7.x or higher (or Windows PowerShell 5.1 on Windows).
Contents
Understanding Azure PowerShell and System Prerequisites
Azure PowerShell is a set of modules designed for managing Microsoft Azure resources directly from the command line or through automated scripts. Modern Azure administration relies entirely on the Az module, which superseded the legacy AzureRM module. Microsoft retired the AzureRM module on February 29, 2024, meaning all updates, security patches, and new service capabilities are published exclusively for the Az module family.
Before executing the installation commands, you must verify that your system environment meets the runtime and security requirements.
Supported Operating Systems and PowerShell Versions
- PowerShell 7.x (Recommended): The
Azmodule is fully cross-platform when paired with PowerShell 7.2 LTS or higher. This is the optimal environment for Windows, macOS, and Linux distributions (such as Ubuntu, Red Hat Enterprise Linux, and macOS Sonoma or later). - Windows PowerShell 5.1: Supported on Windows operating systems only. It requires Microsoft .NET Framework 4.7.2 or later and Windows Management Framework 5.1.
Execution Policy Requirements
On Windows systems, the default execution policy often blocks local script execution and unsigned third-party modules. You must ensure your execution policy allows running modules downloaded from the PowerShell Gallery. To verify and set the execution policy for your user profile, execute:
Get-ExecutionPolicy -Scope CurrentUser Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Setting the policy to RemoteSigned for the CurrentUser scope allows scripts created locally to run without restriction, while requiring scripts downloaded from the internet to carry a digital signature from a trusted publisher.
Method 1: Installing Azure PowerShell via PowerShell Gallery (Recommended)
Installing from the PowerShell Gallery is the standard, cross-platform method for deployment. It ensures you receive the latest release directly from Microsoft's repository and simplifies future module updates.
- Launch PowerShell 7+ or Windows PowerShell 5.1
- Set Execution Policy to RemoteSigned
- Run: Install-Module -Name Az -Scope CurrentUser
- Verify with Connect-AzAccount & Get-AzResource
Step 1: Open PowerShell as an Administrator or User
If you intend to install the module for all users on a shared workstation, launch PowerShell with elevated privileges (Run as Administrator on Windows, or use elevated permissions on Linux/macOS). If you are installing for your own account only, a standard PowerShell session is sufficient.
Step 2: Prepare PowerShellGet and PackageManagement
The PowerShell Gallery uses the PowerShellGet module. If you are using an older build of Windows PowerShell 5.1, your system may prompt you to update the NuGet provider or PowerShellGet package before proceeding. Force an update of NuGet by running:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force
Step 3: Install the Az Module
Execute the primary installation command. Including the -Scope CurrentUser parameter avoids administrative credential prompts and installs the module specifically inside your user profile path:
Install-Module -Name Az -Repository PSGallery -Scope CurrentUser -AllowClobber -Force
-Repository PSGallery: Specifies the official Microsoft PowerShell repository.-Scope CurrentUser: Installs the module into$HOME\Documents\PowerShell\Modules(Windows) or~/.local/share/powershell/Modules(Linux/macOS), preventing write access issues in system-level directories.-AllowClobber: Overwrites conflicting command aliases or functions from older module versions if any exist.-Force: Suppresses diagnostic prompts and automatically trusts required dependencies.
Depending on network bandwidth, the installation process takes between one and three minutes, as the meta-module downloads roughly 100 sub-modules covering individual Azure services (such as Az.Compute, Az.Network, and Az.Storage).
Method 2: Installing Azure PowerShell via MSI Package (Windows Only)
For enterprise environments where network policies restrict direct connection to external galleries, Microsoft provides an MSI (Microsoft Installer) standalone package for Windows systems.
Step 1: Download the Official Installer
Navigate to the official Microsoft Azure PowerShell documentation or GitHub releases page and download the standard Az-Cmdlets MSI package for your platform architecture (x64).
Step 2: Run the Graphical or Unattended Installation
To install using the interactive graphical interface, double-click the .msi file and follow the setup wizard prompts.
For enterprise administrative deployment, automated deployments via System Center Configuration Manager (SCCM), Microsoft Intune, or custom deployment scripts, execute the installer silently from an elevated Command Prompt or PowerShell terminal:
msiexec.exe /i "Az-Cmdlets-x64.msi" /quiet /qn /norestart
Installing via MSI makes the Az module available to all users on the host operating system. However, updating an MSI-installed instance requires downloading and applying subsequent MSI packages or removing the installer entirely to switch back to PowerShell Gallery management.
Method 3: Alternative Environments (Docker Container and Cloud Shell)
If local installation is restricted by policy, or if you require an isolated, pre-configured execution environment, Microsoft offers ready-to-use alternatives.
| Environment | Best For | Setup Requirement |
|---|---|---|
| Azure Cloud Shell | Ad-hoc management, zero local software | Azure Portal Account + Storage Account |
| Docker Container | CI/CD pipelines, consistent builds | Docker Engine installed locally |
| Offline / Airgap | High-security internal networks | Manual transfer via Save-Module script |
Using Azure Cloud Shell
Azure Cloud Shell is an interactive, browser-accessible terminal hosted in Microsoft Azure. It comes pre-installed with the latest version of Azure PowerShell, Azure CLI, and popular developer utilities. You can access it directly via the Azure Portal or by navigating to shell.azure.com. No local installation or local environment maintenance is necessary.
Running via Docker Containers
Microsoft publishes official Docker container images containing PowerShell and the full Az module suite. This approach is standard in continuous integration and continuous deployment (CI/CD) pipelines (such as GitHub Actions or Azure DevOps pipelines).
To launch an interactive Azure PowerShell session inside a container, execute:
docker run -it mcr.microsoft.com/azure-powershell:latest pwsh
Offline / Air-Gapped Installation
To deploy Azure PowerShell onto machines disconnected from the public internet, use a machine connected to the internet to save the module files to a directory or network share:
Save-Module -Name Az -Path "C:\OfflineModules" -Repository PSGallery
Copy the contents of C:\OfflineModules onto USB media or an internal network artifact repository. Move those folder structures into the module path of the target offline system (for instance, C:\Program Files\PowerShell\7\Modules or $env:PSModulePath).
Comparing Azure PowerShell Installation Methods
Selecting the right deployment method depends on your operating system, security restrictions, and update requirements.
| Installation Method | Supported OS | Administrative Rights Needed? | Ease of Updating | Ideal Use Case |
|---|---|---|---|---|
PowerShell Gallery (Install-Module) |
Windows, macOS, Linux | No (when using -Scope CurrentUser) |
Very Easy (Update-Module) |
General workstation usage, developer environments, cross-platform scripting |
| MSI Installer Package | Windows Only | Yes | Moderate (manual download or enterprise patch) | Enterprise desktops, managed endpoints via SCCM/Intune |
| Docker Container | Any host with Docker Engine | No (within container environment) | Very Easy (docker pull) |
CI/CD build agents, isolated script testing, clean room automation |
| Azure Cloud Shell | Any (via Web Browser) | No | Automatic (managed by Microsoft) | Rapid administration, temporary access, zero local footprint |
Verifying Installation and Authenticating to Azure
Once the installation command completes, you should verify that the modules loaded correctly and test your authentication flow to Azure.
Confirming Installed Modules
Run Get-InstalledModule to inspect installed module versions:
Get-InstalledModule -Name Az
To list specific sub-modules loaded into your current session, use:
Get-Command -Module Az.* | Select-Object -First 10
Authenticating to Your Azure Tenant
To initiate an interactive login session, run the primary login command:
Connect-AzAccount
In modern versions of Azure PowerShell, this command opens your system's default web browser, prompting you to enter your Azure account credentials and perform Multi-Factor Authentication (MFA).
# Authenticating via device code (useful for headless servers or SSH sessions) Connect-AzAccount -UseDeviceAuthentication # Viewing details of the active Azure subscription context Get-AzContext
If your account has access to multiple subscriptions, set your target subscription using:
Set-AzContext -SubscriptionId "00000000-0000-0000-0000-000000000000"
Once connected, run a basic resource lookup command to verify full functionality:
Get-AzResourceGroup
Troubleshooting Common Installation Errors
Even standard installations can encounter friction due to legacy configurations, policy restrictions, or system path issues.
Issue 1: "Execution of scripts is disabled on this system"
- Symptom: Running
Install-Moduleor importingAztriggers aPSSecurityException. - Cause: The local system's PowerShell Execution Policy is set to
Restricted(the historical default on Windows desktop operating systems). - Resolution: Change the execution policy for your individual user account without altering machine-wide registry settings:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Issue 2: Conflicts with Legacy AzureRM Modules
- Symptom: Command collisions occurs, or PowerShell throws warnings regarding duplicate cmdlet definitions.
- Cause: Both
Azand the legacyAzureRMmodules exist side-by-side on the host system. - Resolution: Completely remove
AzureRMfrom your environment. Microsoft provides a cleanup helper script via PowerShell Gallery:
If you maintain legacy scripts that depend on old cmdlet names (such asUninstall-Module -Name AzureRM -AllVersions -ForceGet-AzureRmVM), enable aliases within your session rather than keeping the old module installed:Enable-AzureRmAlias -Scope CurrentUser
Issue 3: Untrusted Repository Warning
- Symptom: PowerShell prompts with a warning stating: "You are installing the modules from an untrusted repository."
- Cause: The PowerShell Gallery (
PSGallery) is marked as untrusted by default on fresh Windows installations. - Resolution: Set
PSGalleryto a trusted installation source to eliminate prompts during automated deployments:Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Maintenance: Updating and Uninstalling Azure PowerShell
Maintaining up-to-date modules ensures you retain compatibility with newly launched Azure services, security patches, and API updates.
Updating the Az Module
Because Microsoft frequently releases updates to sub-modules within the Az umbrella, inspect and apply updates regularly. To update all components of the Az module to their latest stable builds, run:
Update-Module -Name Az -Force
Removing Old Versions
Updating modules using Install-Module or Update-Module does not automatically delete old module files; it places the new version side-by-side on your disk drive. To clean up redundant files and free up disk space, uninstall legacy builds using:
Uninstall-Module -Name Az -AllVersions
Then, reinstall the single clean target build using Install-Module -Name Az -Scope CurrentUser.
Frequently Asked Questions
What is the difference between Azure CLI and Azure PowerShell?
Azure CLI is a cross-platform command-line utility built primarily around POSIX-compliant syntax using JSON outputs, suitable for Bash scripts. Azure PowerShell is built on top of .NET and PowerShell, outputting structured object streams rather than text strings, making it ideal for object-oriented scripting and complex Windows enterprise pipelines. Both tools manage the same underlying Azure APIs.
Is AzureRM still supported for Azure PowerShell installations?
No, the legacy AzureRM module reached official end-of-life on February 29, 2024. Microsoft no longer updates, patches, or supports AzureRM. All environments should migrate to the Az module suite immediately.
Can I install Azure PowerShell on macOS or Linux?
Yes. Installing PowerShell 7.x on macOS or Linux allows you to install the Az module directly using the standard Install-Module -Name Az -Scope CurrentUser command inside your cross-platform PowerShell terminal.
Do I need administrative rights to install the Az module?
No administrative rights are needed if you pass the -Scope CurrentUser flag during installation. This routes installation files to your personal user folder. Administrative privileges are only necessary when installing for all users (-Scope AllUsers) or running an MSI installer system-wide.
How do I switch subscriptions after connecting to Azure PowerShell?
After establishing a session via Connect-AzAccount, view available subscriptions using Get-AzSubscription. Switch your active management context to a target subscription ID or name by executing Set-AzContext -Subscription "Your-Subscription-Name".
Next Steps for Azure Automation and Operations
With Azure PowerShell successfully installed and authenticated, your environment is ready to handle automated cloud management tasks. To streamline your administrative workflows:
- Automate Authentication via Service Principals: For automated CI/CD pipelines or unattended scripts, avoid interactive browser logins by configuring authentication using Azure Service Principals or Managed Identities:
Connect-AzAccount -ServicePrincipal -Credential (Get-Credential) -Tenant "your-tenant-id" - Standardize Profile Scripts: Save frequently used contexts, subscription declarations, and aliases inside your
$PROFILEfile so your workstation automatically pre-configures your workspace upon opening a terminal. - Explore Azure Automation: Transition routine host-level scripts into cloud-native Azure Automation Runbooks to schedule tasks, manage governance policies, and execute maintenance operations at scale without maintaining local runner machines.