0
votes

I'm using the Microsoft Graph API within a PowerShell script to automate the creation of Microsoft Teams teams. I am obtaining email addresses from a database of a proprietary non-Microsoft application that does not contain the Microsoft User Id. The Microsoft User ID is needed in order to add members to the Teams.

I am using the Microsoft Graph URI:

graph.microsoft.com/v1.0/users/

to obtain the User Id.

Unfortunately, that database sometimes contains an email alias rather than the user's primary email address. When the script attempts to obtain the person's User Id using an alias, the Graph API call returns an error.

For example, when the primary email is address is "[email protected]", but the database contains his alias "[email protected]" I was expecting to be able to call that API with a filter such as:

graph.microsoft.com/v1.0/users?$filter=alias eq '[email protected]'

but I can find no such filter option.

I would appreciate any tips on how to solve this problem.

1

1 Answers

0
votes

The user object has a property called otherMails. This is a multi-value property.

The filter syntax is different for multi-value-properties.

To filter users by alias, you'll need to use:

https://graph.microsoft.com/v1.0/users?$filter=otherMails/any(c:c eq '[email protected]')