30

I need to find the installed Azure PowerShell version through cmdlets code. How do I find the Azure PowerShell version?

Note: Other than cmdlets code is also welcome.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ManirajSS
  • 2,295
  • 5
  • 26
  • 50
  • does my answer resolve your issue? – juvchan Dec 18 '15 at 23:07
  • here is the latest one: `Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path` – Tim.Tang May 09 '18 at 00:34
  • I tried every other command listed in answer in this post, but none of these works so I just downloaded and installed the latest version using [MSI](https://learn.microsoft.com/en-us/powershell/azure/install-az-ps-msi) as suggested [here](https://stackoverflow.com/a/46596190/1176573). :( – Rajesh Swarnkar Jan 14 '23 at 06:01
  • Wish there was `Get-AzPwshVersion` ! – Rajesh Swarnkar Apr 28 '23 at 16:10

8 Answers8

51

This PowerShell cmdlet will get the Azure PowerShell version.

Get-Module -ListAvailable -Name Azure -Refresh

It has a major advantage in which it will be able to return the expected outcome even if the Azure module has not been loaded into the current PowerShell session.

On the contrary, (Get-Module Azure).Version will only work if the Azure module has been loaded into the current PowerShell session before, i.e. by calling any cmdlet from the Azure module in the current PowerShell session, e.g. Get-AzureStorageAccount

enter image description here

juvchan
  • 6,113
  • 2
  • 22
  • 35
  • 4
    `Get-Module -ListAvailable -Name Azure -Refresh` is not listing Version and Name columns.Am i missing anything else? – ManirajSS Feb 24 '16 at 16:33
  • Hi @ManirajSS, I retry exactly the same command and is able to get the expected result as shown in my answer. May I know what powershell version and platform you're running on? My current Azure PowerShell version is 1.0.4. – juvchan Feb 24 '16 at 21:31
  • 2
    @juvchan When I run your cmdlet in Windows Powershell it returns your output, but when I run it in Microsoft Azure Powershell it returns `ModuleType Name ExportedCommands ---------- ---- ---------------- Manifest Azure {New-AzureServiceRemoteDesktopExtensionConfig, New-AzureStorageContext, ... `, without Version /cc @ManirajSS – Frank van Eykelen Apr 01 '16 at 13:42
  • 1
    The output of this command depends upon the version of powershell you are using. The output in the answer is from powershell 5.0, whereas the output in @FrankvanEykelen comment is from powershell 3.0. Use $PSVersionTable.PSVersion to check your powershell version – Mick Jun 30 '16 at 01:06
13

Use:

(Get-Module azure).Version

This will return version of installed Azure PowerShell.

Azure PowerShell version

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ManirajSS
  • 2,295
  • 5
  • 26
  • 50
  • 10
    This solution will not work if the Azure module has not been loaded into the current PowerShell session. It will just return empty, tested on my environment. It only works when I have called any cmdlet from the Azure module in the current PowerShell session. – juvchan Dec 08 '15 at 14:20
  • 4
    For me that's what worked: `(Get-Module -ListAvailable -Name Azure -Refresh).Version` – Leonel Jul 12 '16 at 01:07
  • See the answer by Jonathan-Gao that uses the Get-InstalledModule command – TxRegex Jul 14 '21 at 12:59
13
Get-InstalledModule -Name Az -AllVersions | select Name,Version

It is documented in https://learn.microsoft.com/en-us/powershell/azure/install-az-ps.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Jonathan Gao
  • 599
  • 3
  • 9
6

You can use the following cmdlet to get the Azure PowerShell version as well!

Copy and paste the following, and run it!

(Get-Module -ListAvailable | Where-Object{ $_.Name -eq 'Azure' }) ` | Select Version, Name, Author, PowerShellVersion  | Format-List;
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Icecream
  • 69
  • 1
  • 1
3
Get-Module AzureRM -List | Select-Object Name, Version, Path

This is great to run if you have multiple versions running.

Jules
  • 31
  • 2
3

Use official :
$PSVersionTable.PSVersion

harry
  • 159
  • 7
  • This should be the answer. – John Stud Nov 30 '21 at 03:28
  • 2
    For me, this command just gives me the powershell version without any reference to AzureAd. For me, I'm using azure online, so I can get the info with this command: `Get-Module Azuread -ListAvailable | Select-Object -Property Name,Version,Path` – bgmCoder Jun 23 '22 at 15:36
1

It runs in AzureServiceManagementMode and not in ARM mode in version 0.8 and 0.9. It works smooth with the version 1.0 and above.

 $name='Azure' 

    if(Get-Module -ListAvailable |  Where-Object { $_.name -eq $name })  
    {  
      (Get-Module -ListAvailable | Where-Object{ $_.Name -eq $name }) |  Select Version, Name, Author, PowerShellVersion  | Format-List;  
    }  
    else  
    {  
        “The Azure PowerShell module is not installed.” 
    }

enter image description here

Cheers!!

Rahul Mohan
  • 493
  • 3
  • 5
  • 18
1

Running the following command in PowerShell gives me the current Azure PowerShell version.

Get-Module -ListAvailable -Name Az

Dilan Perera
  • 131
  • 1
  • 2
  • 7