This script uses Azure Resource Graph to query the Azure subscription you specify or all of the subscriptions that you have access to with the intent of counting the number of cores and VMs to caluclate the number of licenses needed to cover those VMs that have AHUB enabled.
There are a few things to keep in mind when running this script:
- In order to run this script you will need to install the Resource Graph modules from the Powershell Gallery by using the following command:
Install-Module -Name AzureRm.ResourceGraph -AllowPrerelease - You have to be logged in to Azure via PowerShell before using this script. This is also using some of the older commands, so you may also need to issue the Enable-AzureRmAlias command
- Update the $SubscriptionID variable line with the subscription ID that you want to search or clear it out to search all of the subscriptions that you have access.
- Additional information on how to calculate Azure Hybrid Use Benefits can be found here.
Please note that this is an example and is meant to help collect the relavent information needed to determine how many licenses you would need. This is not meant to be any official reporting mechanism.