SOLVED

Get-MgUser - how to get only users?

Copper Contributor

Is there a filter for this command to get only users and no rooms and resources as result?

8 Replies
I can't find solution there.

@Benjamin1998  Get-MgUser -All -Filter "userType eq 'member'"

 

See https://office365itpros.com/2022/03/24/azure-ad-user-account-powershell/ for lots more about Get-MgUser

Well, even the examples show some pointers. You better head off to Tonys article.
Hello Tony,
I always get users and ressources.
How to get only users?
best response confirmed by Benjamin1998 (Copper Contributor)
Solution

@Benjamin1998 Azure AD doesn’t distinguish between an account used by a human and one used by a resource, like a shared mailbox. You’ll have to filter the set returned to get the data you want. This is one reason why I often use Get-

ExoMailbox instead as it’s easier to filter the set.

Hello Toni,
I can use Get-ExoMailbox instead.
Thanks!

Hi @Benjamin1998 
Maybe you already know this, but you know you could use Select-MgProfile beta as it will provide you with more attributes (163 instead of 138 @time of this reply).
I found “AssignedLicenses” useful.
Please remember that beta can change any time and MS does not recommend it for production.

1 best response

Accepted Solutions
best response confirmed by Benjamin1998 (Copper Contributor)
Solution

@Benjamin1998 Azure AD doesn’t distinguish between an account used by a human and one used by a resource, like a shared mailbox. You’ll have to filter the set returned to get the data you want. This is one reason why I often use Get-

ExoMailbox instead as it’s easier to filter the set.

View solution in original post