Last active
November 13, 2017 10:21
-
-
Save faizan002/f86c9aac6016c70043733f6f666d1ef4 to your computer and use it in GitHub Desktop.
Calculate number of ResourceGroups with same prefix string in name. (Microsoft Azure - Powershell)
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
$vmNamePrefix="SomeString" | |
$existingNumberOfRGs = $(Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like "$vmNamePrefix*"}).count | |
$nextRGNumber = $existingNumberOfRGs + 1 | |
$rgName = $rgNamePrefix + "$nextRGNumber" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.