chelnak
3/10/2017 - 10:24 AM

Small profile function to easily retrieve a list of API versions for a given Resource Type

Small profile function to easily retrieve a list of API versions for a given Resource Type

function Get-AzureRMResourceTypeAPIVersion {
<#

    .SYNOPSIS
    Retrieve a list of API versions for a given ResourceTypeName

    .DESCRIPTION 
     Retrieve a list of API versions for a given ResourceTypeName

    .PARAMETER ProviderNamespace
    The the namespace of for the provider of the ResourceTypeName

    E.g. Microsoft.Network

    .PARAMETER ResourceTypeName
    The type of resource to query

    E.g. loadBalancers

    .EXAMPLE
    Get-AzureRMResourceTypeAPIVersion -ProviderNamespace "Microsoft.Network" -ResourceTypeName loadBalancers

#>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true, Position=0)]
        [ValidateNotNullOrEmpty()]
        [String]$ProviderNamespace,

        [Parameter(Mandatory=$true, Position=1)]
        [ValidateNotNullOrEmpty()]
        [String]$ResourceTypeName
    )

    (Get-AzureRmResourceProvider -ProviderNamespace $ProviderNamespace).ResourceTypes | `
        Where-Object {$_.ResourceTypeName -eq $ResourceTypeName} | `
        Select-Object -ExpandProperty "ApiVersions"
        
}