Forum Discussion
EntilZha
Jan 10, 2020Iron Contributor
Microsoft Graph Filter by specific Domain Name
I have over 20000 users and we have four sub-domain. I'm trying reduce the results when making a Graph call by only calling those users with a specific userPrincipalName sub-domain. When I execut...
- Jan 10, 2020
As noted in the documentation, only startswith and eq operators are supported for userPrincipalName. Welcome to the wonderful world of crappy oData filtering...
Michael-Schmitz
Aug 08, 2022Brass Contributor
Sadly the endsWith query-filter ist not supported yet. But there is a way around it, it's not so elegant since we're first getting all the users and then reselect the ones with the specific domain:
Connect-MgGraph -Scopes "User.Read.All"
$DisabledDomainUsers = Get-MgUser -Filter 'accountEnabled eq false' -All | Where-Object {$_.Mail -like "*@domain.ch"}
The following Modules are needed to use the commands above:
Install-Module Microsoft.Graph -Scope CurrentUser
Install-Module Microsoft.Graph.Users -Scope CurrentUser