Skip to content

Instantly share code, notes, and snippets.

@faizan002
Last active November 13, 2017 10:21
Show Gist options
  • Save faizan002/f86c9aac6016c70043733f6f666d1ef4 to your computer and use it in GitHub Desktop.
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)
$vmNamePrefix="SomeString"
$existingNumberOfRGs = $(Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like "$vmNamePrefix*"}).count
$nextRGNumber = $existingNumberOfRGs + 1
$rgName = $rgNamePrefix + "$nextRGNumber"
@faizan002
Copy link
Author

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