**Get the Count of AAD Group Members, Including Subgroups** When working with Azure Active Directory (AAD) groups, it's often helpful to get a count of the group members, including any subgroups. This can be a useful tool for administrators and managers looking to track membership in their organizations. In this blog post, we'll explore a PowerShell script that does just that. The script uses the AzureAD PowerShell module to connect to your AAD instance, retrieve the list of groups that match a specific criteria (in this case, containing a certain string), and then recursively count the members of each group and its subgroups. **Prerequisites** * AzureAD PowerShell module installed * An Azure Active Directory tenant with the necessary permissions **The Script**

Clear-Host
Connect-AzureAD

$output = @()
$groups = Get-AzureADMSGroup -all $true | where {$_.DisplayName -like '*[your_group_here]*'} | Select ID, Displayname | sort-object Displayname