Skip to content

Instantly share code, notes, and snippets.

@markwragg
Last active April 5, 2018 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markwragg/0f6a91e8eeb6c5515a09ac29c862307f to your computer and use it in GitHub Desktop.
Save markwragg/0f6a91e8eeb6c5515a09ac29c862307f to your computer and use it in GitHub Desktop.
Get Azure subnets for a VNET and sort them correctly by address by recasting them to [version]
$VNET = Get-AzureRmVirtualNetwork -name VNET_NAME -ResourceGroupName RG_NAME
(Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNET).AddressPrefix | ForEach-Object {
$Net = $_ -split '/'
[pscustomobject]@{
Address = [version]$Net[0]
Mask = $Net[1]
}
} | Sort Address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment