Find your Windows Azure PowerShell cmdlets version.

I don’t know if you notice when you go to download the latest version of Windows Azure PowerShell cmdlets, the version number is no longer displayed  on the Download page.  As you already know, Azure PowerShell commands gets updated sporadically, so you need to periodically check if there are new updates.  The download page was previously giving you the hint that there was an updated set of commands.

Last year Windows Azure Download page used to display the Azure PowerShell version which made it easy to check for the updated product:

Last year Windows Azure PowerShell version displayed

Last year Windows Azure PowerShell version displayed

Currently, as of February 2014, the version number is Gone!

Windows Azure PowerShell version is Gone!

Windows Azure PowerShell version is Gone!

Well,  here’s where PowerShell comes to the rescue.

The following quick code can query both you current version and check for the latest version available on the Internet. And, Yes! This code can be improved and taken a little further.  But, this will give you a head start.

Get-WindowsAzurePowerShellVersion function:WindowsAzurePowerShell_00

Copy/Paste code in PowerShell Console.

WindowsAzurePowerShell_01

View Results.

WindowsAzurePowerShell_02

Notice the first portion of the code uses WMIWin32_Product” Class which will take a few minutes to query your system for what’s installed.  By a strong recommendation from my MVP college Aleksandar Nikolic I change the code from using the WMI Win32_Product class and instead use the Get-Module Version property. This way it will effectively provide the needed information.

Then, for the “Microsoft.Web.PlatformInstaller” piece, if you previously installed Windows Azure PowerShell (or any of the other options), this assembly will be already in your system.

Note: My college Aleksandar Nikolic suggested not to use Win32_Product. BAD IDEA!!  Check the following links why not to use “Win32_Product“:

So, I corrected the code below following Alek suggestion.

If you want to further learn to further automate your Azure PowerShell download and installation, I recommend you to read the following article at the “PowerShell Magazine“: http://www.powershellmagazine.com/2014/02/27/using-powershell-and-web-platform-installer-to-install-azure-powershell-cmdlets/

Keep learning PowerShell!

Script Code:

function Get-WindowsAzurePowerShellVersion
{
[CmdletBinding()]
Param ()

## - Section to query local system for Windows Azure PowerShell version already installed:
Write-Host "`r`nWindows Azure PowerShell Installed version: " -ForegroundColor 'Yellow';
(Get-Module -ListAvailable | Where-Object{ $_.Name -eq 'Azure' }) `
| Select Version, Name, Author | Format-List;

## - Section to query web Platform installer for the latest available Windows Azure PowerShell version:
Write-Host "Windows Azure PowerShell available download version: " -ForegroundColor 'Green';
[reflection.assembly]::LoadWithPartialName("Microsoft.Web.PlatformInstaller") | Out-Null;
$ProductManager = New-Object Microsoft.Web.PlatformInstaller.ProductManager;
$ProductManager.Load(); $ProductManager.Products `
| Where-object{
($_.Title -match "Windows Azure PowerShell") `
-and ($_.Author -eq 'Microsoft Corporation')
} `
| Select-Object Version, Title, Published, Author | Format-List;
};

This entry was posted in Azure, PowerShell. Bookmark the permalink.