Skip to content

Instantly share code, notes, and snippets.

@marckean
Created April 14, 2020 22:23
Show Gist options
  • Save marckean/4afca5217e4d3e1aa5b06a90547b1f4d to your computer and use it in GitHub Desktop.
Save marckean/4afca5217e4d3e1aa5b06a90547b1f4d to your computer and use it in GitHub Desktop.
<#
Written with version 3.5.0 of the Azure PowerShell Module
available from here https://github.com/Azure/azure-powershell/releases/tag/v2.8.0-October2019
Install-Module -Name Az -Repository PSGallery -RequiredVersion 3.5.0 -Force -AllowClobber
Migration instructions Azure.RM to Az - https://azure.microsoft.com/en-au/blog/how-to-migrate-from-azurerm-to-az-in-azure-powershell/
#>
Login-AzAccount | Out-Null
$subscriptions = Get-AzSubscription
$cnt = 1
Write-Host "ID Subscription Name"
Write-Host "-----------------------"
foreach ($sub in $subscriptions){
Write-Host "$cnt $($sub.name)"
$cnt++
}
$selection = Read-Host -Prompt "Select a subscription to deploy to"
$subSelect = $subscriptions[$selection - 1] # Revert 1-index to 0-index
Select-AzSubscription $subSelect.SubscriptionId
#############################################################################
$CommunityNames = (Get-AzBgpServiceCommunity).BgpCommunities.CommunityName
$cnt = 1
foreach ($CommunityName in $CommunityNames){
Write-Host "$cnt $CommunityName"
$cnt++
}
$selection = Read-Host -Prompt "Select a Community Name to get the BGP communities"
$CommunityNameSelect = $CommunityNames[$selection - 1] # Revert 1-index to 0-index
Get-AzBgpServiceCommunity | ? {$_.BgpCommunities.CommunityName -eq $CommunityNameSelect}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment