Last active
January 14, 2021 16:09
-
-
Save bmoore-msft/126980ad876085106a4342db83b5c27b to your computer and use it in GitHub Desktop.
Get the api versions and locations for a resource type published in the manifest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function api { | |
<# | |
.Synopsis | |
Get the api versions and locations for a resource type. | |
.Description | |
Lists all the available api versions and locations for a given resource type. Information is pulled from the /providers api | |
which returns the information in the manifest published to ARM. | |
.Notes | |
The resource parameter requires the format of Namespace/type, e.g. Microsoft.Storage/storageAccounts | |
> api Microsoft.Storage/storageAccounts | |
#> | |
param( | |
[Parameter(Mandatory = $true)][String]$resource | |
) | |
$a = $resource.Split('/', 2) | |
$ProviderNameSpace = $a[0] | |
$resourceTypeName = $a[1] | |
Write-Host $ProviderNameSpace | |
Write-Host $resourceTypeName | |
$resourceTypes = (Get-AzResourceProvider -ProviderNamespace $ProviderNameSpace).ResourceTypes | |
($resourceTypes | where-object { $_.ResourceTypeName -eq "$resourceTypeName" }).apiVersions | |
$v = ($resourceTypes | where-object { $_.ResourceTypeName -eq "$resourceTypeName" }).locations | |
$locations = @() | |
foreach($l in $v){ | |
$locations += $l.replace(" ", "").toLower() | |
} | |
$locations | Sort-Object | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment