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:
Currently, as of February 2014, the version number 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:
Copy/Paste code in PowerShell Console.
View Results.
Notice the first portion of the code uses WMI “Win32_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“:
- http://sdmsoftware.com/group-policy-blog/wmi/why-win32_product-is-bad-news/
- http://csi-windows.com/toolkit/win32product-replacement
- http://support.microsoft.com/kb/974524
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:
[sourcecode language=”powershell”]
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;
};
[/sourcecode]