Azure PowerShell

Install Azure PowerShell


If you select Azure PowerShell as your automation solution. Your administrators prefer to run their scripts locally rather than in the Azure Cloud Shell. The team uses machines that run Linux, macOS, and Windows. You need to get Azure PowerShell working on all their devices

Using the PowerShellGet cmdlets is the preferred installation method. Install the Az module for the current user only. This is the recommended installation scope. This method works the same on Windows, macOS, and Linux platforms. Run the following command from a PowerShell session:

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    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.

Installing the module for all users on a system requires elevated privileges. Start the PowerShell session using Run as administrator in Windows or use the sudo command on macOS or Linux:


Install offline

In some environments, it's not possible to connect to the PowerShell Gallery. In those situations, you can still install offline using one of these methods:


  • Download the modules to another location in your network and use that as an installation source. This method allows you to cache PowerShell modules on a single server or file share to be deployed with PowerShellGet to any disconnected systems. Learn how to set up a local repository and install on disconnected systems with Working with local PowerShellGet repositories.

  • Download the Azure PowerShell MSI to a machine connected to the network, and then copy the installer to systems without access to PowerShell Gallery. Keep in mind that the MSI installer only works for PowerShell 5.1 on Windows.

  • Save the module with Save-Module to a file share, or save it to another source and manually copy it to other machines:

    Save-Module -Name Az -Path '\\server\share\PowerShell\modules' -Force

To use Azure PowerShell in PowerShell 5.1 on Windows:
  1. Update to Windows PowerShell 5.1. If you're on Windows 10 version 1607 or higher, you already have PowerShell 5.1 installed.
  2. Install .NET Framework 4.7.2 or later.
  3. Make sure you have the latest version of PowerShellGet. Run Install-Module -Name PowerShellGet -Force.

Comments

Popular posts from this blog

Develop Azure Compute Solutions (25-30%)