简体   繁体   中英

How do I get all users in my company with a specific filter in microsoft graph API

With Microsoft Graph API, I'm trying to get all users in my company but with a specific filter such as mail = (*@company.com).. The reason I cannot just use /users is because we have many third-party and administrator (dup) accounts. I just want to retrieve the ones with a valid *@company.com email.

I've tried a few of these, but does not work:

https://graph.microsoft.com/v1.0/users?$filter=mail eq '*@company.com'
https://graph.microsoft.com/v1.0/users?$filter=startswith(mail, '*@company.com')

I should also mention I am using POSTMAN to test and will implement into the Microsoft Graph SDK for PHP (msgraph-sdk-php).

Appreciate any help!

You are trying to achieve ending of the particular string but Microsoft Graph endpoints currently don't support endsWith or similar query parameters. From the documentation on query parameters .

Suggestion is to use PowerShell instead.

Example,

$Users=Get-AzureADUser -All:$true | Where-Object {$_.UserPrincipalName -clike "*onmicrosoft.com"} | Select UserPrincipalName

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM