Skip to content

Instantly share code, notes, and snippets.

@faizan80 faizan80/NumberOfRG.ps1
Last active Nov 13, 2017

What would you like to do?
Calculate number of ResourceGroups with same prefix string in name. (Microsoft Azure - Powershell)
$existingNumberOfRGs = $(Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like "$vmNamePrefix*"}).count
$nextRGNumber = $existingNumberOfRGs + 1
$rgName = $rgNamePrefix + "$nextRGNumber"

This comment has been minimized.

Copy link
Owner Author

faizan80 commented Nov 13, 2017

This gist is in powershell.
It takes a string as input.
Uses this string to find Resource Groups in Azure whose name starts with this string.
This is useful if name of RG is to be selected automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.