A quick note, this requires the newer AzureAdPreview module, as some of the fields retrieved by the Get-AzureADMSGroup command are not present in the current AzureAd module.
# script to get a list of all Azure AD DYnamic Groups and rules.
# This requires the azureadpreview module
# install-module azureadpreview
# you will need to remove the regular azuread module if you have in installed first!
Connect-AzureAD
$groups=Get-AzureADMSGroup -All $true
$dyngroups=@()
foreach ($group in $groups)
{
#lets filter out only dynamic groups
if($group.grouptypes -eq "DynamicMembership")
{
$dyngroups+= $group
}
}
$dynamicrules = @()
foreach($dyngroup in $dyngroups)
{
$hashtable =[ordered]@{}
$hashtable.groupname = $dyngroup.displayname
$hashtable.membershiprule = $dyngroup.MembershipRule
$dynamicrules += New-Object psobject -Property $hashtable
}
$dynamicrules | out-gridview
