This script retrieves the locations of the Microsoft.ContainerService resource provider that contain managedClusters resource types, then for each location, it retrieves the available versions of Azure Kubernetes Service (AKS) using the Get-AzAksVersion
command, selects specific properties (OrchestratorVersion, IsPreview, Default) from the retrieved data, adds a new property named "Location" to each object in the retrieved data with the current location, and finally appends the modified data to the $output array.
$resourceProviderLocations = (Get-AzResourceProvider -ProviderNamespace Microsoft.ContainerService | Where-Object {$_.ResourceTypes.ResourceTypeName -contains "managedClusters"}).Locations $output = @() foreach ($location in $resourceProviderLocations) { $data = Get-AzAksVersion -location $location | Select-Object -Property OrchestratorVersion, IsPreview , Default $data | Add-Member -MemberType NoteProperty -Name Location -Value $location -PassThru $output += $data }