Freigeben über


PowerShell Azure - Get-AzureExtensionHighestVersion

function Get-AzureExtensionHighestVersion {
   [CmdletBinding()]
   PARAM ([string]$extension, [string] $location='AustraliaEast') 

   $sortProps = @{Expression = "PublisherName"; Descending = $True}, @{Expression = "Type"; Descending = $True},@{Expression = "Version"; Descending = $True}
   $Results= Get-AzureRmVmImagePublisher -Location $location |      Get-AzureRmVMExtensionImageType |       Get-AzureRmVMExtensionImage |
       Where-Object {$_.Type -LIKE "*$extension*"}

  #replace version text with version object type   $versions=$Results | Select-Object -Property PublisherName, Type, @{N='Version';E={([version] $_.Version)}}

  # first sort the whole table, then groupby on a dummy key of Publisher+Type
   # - then we only want the first from each group. voila!

  $output = $versions | Sort-Object $sortProps |   Select-Object *,@{N='XXX';E={$_.PublisherName+' '+$_.Type }} | Group-Object -Property XXX |      Foreach-Object {$_.Group[0] | Select-Object Type,PublisherName,Version}

  $output }

 

Get-AzureExtensionHighestVersion DSC