Skip to content
ApEasyFleet.

Smarter Fleet Management

Education & Enterprise

How to Install Azure PowerShell: A Comprehensive Setup and Configuration Guide

Installing Azure PowerShell provides administrators and developers with a robust command-line environment to manage, automate, and provision Microsoft Azure cloud resources directly from their local workstations or continuous integrati...

Installing Azure PowerShell provides administrators and developers with a robust command-line environment to manage, automate, and provision Microsoft Azure cloud resources directly from their local workstations or continuous integration servers. By utilizing Az, the official PowerShell module for interacting with Azure, users can execute hundreds of granular cmdlets to handle everything from simple virtual machine start-stop sequences to complex multi-tier architectural deployments. This comprehensive walkthrough details the exact prerequisites, installation methodologies across multiple operating systems, verification procedures, and troubleshooting techniques required to establish a stable and secure Azure automation workstation.

Contents

Understanding Azure PowerShell and Prerequisites

Before initiating the installation process, it is critical to understand the architecture of Azure PowerShell and ensure your system meets the necessary software and security prerequisites. Azure PowerShell operates as a set of modules for PowerShell, allowing you to run commands that interact with Azure Resource Manager (ARM) APIs. Over the years, Microsoft transitioned from the older AzureRM module to the modern Az module, which offers cross-platform support, smaller package sizes, better performance, and automatic breaking-change reduction features.

The foundational requirement for running modern Azure PowerShell is having a compatible PowerShell host installed on your machine. PowerShell version 7 or higher is strongly recommended for production environments and cross-platform use, though Windows PowerShell 5.1 remains supported exclusively on Windows operating systems for legacy compatibility. Furthermore, your machine must have internet access to fetch the modules from the PowerShell Gallery (PSGallery), which serves as the central repository for PowerShell content.

System Prerequisites Checklist

  • Operating System: Windows 10 or 11, Windows Server 2016 or newer, macOS (Catalina or later), or supported Linux distributions (such as Ubuntu, CentOS, or RHEL).
  • PowerShell Host: PowerShell 7+ (Recommended for Windows, macOS, and Linux) or Windows PowerShell 5.1 (Windows only).
  • Execution Policy: Appropriate script execution policies configured to allow module loading and script execution.
  • Administrator Privileges: Local administrator or root access may be required depending on whether you install the module for all users or strictly for the current user profile.

Installing Azure PowerShell on Windows

Windows environments offer the most flexible installation options for Azure PowerShell, ranging from standard user-scope installations that require no administrative rights to machine-wide deployments suitable for shared servers and multi-user workstations.

Method 1: Installing via the PowerShell Gallery (Recommended)

The standard and most up-to-date method for installing the Az module on Windows involves utilizing the PowerShellGet module, which connects directly to the PowerShell Gallery. Open your PowerShell console with standard or elevated permissions depending on your target scope.

To install the module for the current user (which avoids permission barriers and UAC prompts), execute the following command:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

If you manage a shared workstation or a dedicated build server and need the module available to all local user accounts, launch an elevated PowerShell prompt (Run as Administrator) and execute:

Install-Module -Name Az -Scope AllUsers -Repository PSGallery -Force

During this process, PowerShell may prompt you to install the NuGet provider or trust the PSGallery repository if you have not interacted with it previously. Confirm these prompts by typing Y or A (Yes to All) to proceed with the download and compilation of the module packages.

Method 2: Offline and Enterprise Deployment Considerations

For enterprise environments with strict security postures, outbound internet access to the public PowerShell Gallery is often blocked. In such scenarios, administrators must download the Az module package (.nupkg) on an internet-connected staging machine using Save-Module, transfer the files via secure internal channels to the isolated target node, and run Install-Module pointing to the local file path.

Azure Powershell インストール Windows10, Azure Powershell Install - UKURU

Installing Azure PowerShell on macOS and Linux

Because the modern Az module is built on .NET, it runs natively across macOS and Linux distributions via PowerShell 7+. This cross-platform capability ensures that cloud engineers managing mixed-infrastructure environments can maintain identical automation scripts regardless of their local operating system.

Installing PowerShell Core on macOS

On macOS, the most efficient method for managing packages and dependencies is Homebrew. Open your Terminal application and install PowerShell by executing:

brew install --cask powershell

Once the installation finishes, launch PowerShell by typing pwsh in your terminal window. From within the PowerShell prompt, install the Az module using the standard gallery command:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

Installing PowerShell on Linux (Ubuntu / Debian Example)

Linux installations typically require registering Microsoft’s official package repositories before installing PowerShell. For Ubuntu-based distributions, follow these sequential steps in your terminal:

  1. Update the local package list and install prerequisite packages:
    sudo apt-get update
    sudo apt-get install -y wget apt-transport-https software-properties-common
    
  2. Download and register the Microsoft repository signing key:
    wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
    sudo dpkg -i packages-microsoft-prod.deb
    
  3. Update package lists and install PowerShell:
    sudo apt-get update
    sudo apt-get install -y powershell
    
  4. Launch PowerShell and install the Az module:
    pwsh
    Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
    

Installation Methods Comparison

To help determine the optimal setup path for your operational environment, the following comparison matrix outlines the primary installation routes, target audiences, and permission requirements.

Installation Method Target Environment Administrative Rights Required Scope / Visibility Best Suited For
Current User Scope Windows, macOS, Linux No Current user profile only Developer workstations, restricted corporate laptops
All Users Scope Windows Server, Multi-user PCs Yes (Administrator) Machine-wide Shared administrative servers, build agents
Offline Package Save Air-gapped / Isolated Networks Yes (Usually) Local repository or All Users Highly secure enterprise datacenters
Cloud Shell (Browser) Web-based Azure Portal No Transient cloud container Quick fixes, testing, zero-footprint management

Verifying the Installation and Managing Updates

Once the installation script completes successfully, you must verify that the modules are correctly loaded and responsive. Close and reopen your PowerShell console to refresh the environment paths, then check the installed module version by running:

Get-Module -Name Az -ListAvailable

This command should output the exact version number of the Az module family installed on your system. To ensure your environment remains secure and compatible with newly released Azure features, you should update your modules periodically. Unlike older tools, the Az module provides a built-in cmdlet designed specifically for updating all sub-modules simultaneously:

Update-Module -Name Az -Force

Note: The -Force parameter ensures that newer dependency versions overwrite older cached files without generating conflicting version prompts.

Initial Authentication and Connecting to Azure

With the software installed and verified, the final step involves establishing a secure authenticated session between your local machine and your Microsoft Azure subscription. Azure PowerShell supports multiple authentication mechanisms, ranging from interactive browser sign-ins to automated service principal credentials used in CI/CD pipelines.

Interactive User Sign-In

For everyday administrative tasks and local script development, interactive login is the standard approach. Execute the following cmdlet in your PowerShell session:

Connect-AzAccount

This action will trigger a web browser window prompting you to enter your Azure Active Directory (Microsoft Entra ID) credentials. Once successfully authenticated, the console output will display an overview of your account details, tenant ID, and active subscription associations.

If your user account is associated with multiple Azure subscriptions, you can list them using Get-AzSubscription and select the active working subscription via:

Set-AzContext -SubscriptionId "your-subscription-id-here"

Common Installation Challenges and Troubleshooting

While the PowerShell Gallery installation process is generally seamless, administrators occasionally encounter environmental blocks or dependency conflicts. Reviewing these common pitfalls can prevent deployment delays.

Script Execution Policy Restrictions

On fresh Windows installations, the default execution policy (Restricted) prevents PowerShell from loading scripts and modules. If you receive an error stating that script execution is disabled on your system, you can adjust the policy for your current user scope without compromising system-wide security:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Untrusted Repository Prompts

If your system prompts you to confirm repository trust during Install-Module, it indicates that the PSGallery is not marked as trusted in your local PowerShell configuration. You can bypass future interactive prompts in automated scripts by explicitly setting the repository trust level:

Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

Outdated PowerShellGet Version

Older Windows PowerShell 5.1 environments often feature legacy versions of the PowerShellGet module, which cannot communicate securely with modern HTTPS endpoints hosting the PowerShell Gallery. If installation commands fail with unexpected parsing errors or connection timeouts, update the package provider first:

Install-Module -Name PowerShellGet -Force -AllowClobber

Next Actions and Operational Best Practices

After successfully installing and verifying Azure PowerShell, you are ready to begin automating cloud workflows. To maintain a secure and efficient administrative posture, adhere to these professional practices:

  1. Leverage Azure Cloud Shell: If you require immediate access without local installation overhead, press the Cloud Shell icon in the Azure Portal (>_) to access a pre-configured, authenticated PowerShell environment hosted directly in Azure.
  2. Adopt Service Principals for Automation: Never hardcode interactive user credentials into production automation scripts. Utilize Azure Service Principals with managed identities or certificate-based authentication for scheduled tasks and deployment pipelines.
  3. Audit Module Versions: Regularly check release notes on the official Microsoft documentation pages to track breaking changes when updating major versions of the Az module.

Frequently Asked Questions

Can I install Azure PowerShell alongside Azure CLI?

Yes. Azure PowerShell (the Az module) and Azure CLI are independent tools that can coexist on the same workstation without interfering with one another. Many administrators install both to leverage CLI for quick JSON-based queries and PowerShell for complex, object-oriented automation scripts.

Do I need administrative rights to install Azure PowerShell?

No. By specifying -Scope CurrentUser during the Install-Module execution, you install the module directly into your user profile directory ($HOME\Documents\PowerShell\Modules), which requires zero administrative privileges on Windows, macOS, or Linux.

How do I uninstall older AzureRM modules?

If you are transitioning from the legacy AzureRM module to the modern Az module, you should uninstall AzureRM to prevent cmdlet name collisions and syntax errors. Run Uninstall-AzureRm using the community-provided migration tools or remove the module directories manually from your PowerShell module path.

What is the difference between Az and AzureRM?

The Az module is the modern, cross-platform replacement for AzureRM. It features smaller download sizes, reduced memory overhead, support for PowerShell 7+, and cleaner cmdlet naming conventions while providing identical or superior coverage of all Azure resource management features.

How can I run Azure PowerShell scripts without internet access?

You can use an offline installation strategy by downloading the .nupkg package from the PowerShell Gallery onto an internet-connected computer via Save-Module -Name Az -Path "C:\Temp", copying the files to your air-gapped server, and running Install-Module -Name Az -Source "C:\Temp".

Why does my installation fail with a TLS connection error?

Older operating systems—particularly unpatched Windows Server versions—may default to TLS 1.0 or 1.1, which the PowerShell Gallery rejects for security compliance. Fix this by forcing PowerShell to use Transport Layer Security 1.2 before running your install commands: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12.

Written by

Gregory Vance

Global Digital Strategy Correspondent

You Might Also Like

View All