Skip to content

Instantly share code, notes, and snippets.

@NielsS79
Last active March 14, 2022 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NielsS79/4f200359540ec4fe930d675112475865 to your computer and use it in GitHub Desktop.
Save NielsS79/4f200359540ec4fe930d675112475865 to your computer and use it in GitHub Desktop.
Find an Azure AD (Dynamic) group by a keyword in its membership query.
<#
.SYNOPSIS
This oneliner will fetch all Azure AD Dynamic Membership groups, matching a keyword to its membership query.
.DESCRIPTION
Get-AzureADMSGroup is basically Get-AzureADGroup via Graph API. It's more flexible but also a little tricky.
Using the -Filter below we only fetch groups where the GroupTypes property (collection) contains a 'DynamicMembership' value.
Unfortunately the contains() filter operator isn't implemented (there is startsWith() though) so we need to iterate over all results to find $SearchString matches.
.NOTES
Author: Niels Scheffers <niels.scheffers@etesian.nl>
Last modified: 2022-03-10
#>
Get-AzureADMSGroup -Filter "GroupTypes/any(s:s eq 'DynamicMembership')" | Where-Object -Property DisplayName -Like '*keyword*';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment