question

frob avatar image
0 Votes"
frob asked frob edited

What PowerShell command can detect if a user/guest user exists in Azure AD?

Hi there

What PowerShell command can detect if a user/guest user exists in Azure AD? E.g. how to check if someone@gmail.com exists in our AAD?

Thank you.

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

frob avatar image
0 Votes"
frob answered frob edited

Hi all

In case someone else needs this, I was able to resolve this using https://stackoverflow.com/questions/51946089/powershell-checking-if-an-azure-ad-guest-already-exists

 Get-AzureADUser -ObjectId "$($email -replace "@", "_")#EXT#@tenant.onmicrosoft.com"

Thank you all :-)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Gops avatar image
0 Votes"
Gops answered frob commented

Hello, you navigate to AAD User and filter Guest and export the list. also you can use Graph to pull the same information.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Gops
I have to check a list of several hundred users, so need a PowerShell way. Looking for the exact command that can check a user exists in AD as a Guest User.
Thanks so much.

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered frob commented

Have you tried using the Get-AzureADUser cmdlet?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RichMatheisen-8856
Get-AzureADUser works for a user but is not working for Guest Users in AAD. Do you know any PowerShell way to detect a guest user in AD?
Thanks.

0 Votes 0 ·
frob avatar image
0 Votes"
frob answered

Hi all

In case someone else needs this, I was able to resolve this using https://stackoverflow.com/questions/51946089/powershell-checking-if-an-azure-ad-guest-already-exists

Thank you all :-)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Gops avatar image
0 Votes"
Gops answered Gops published

Hello,

Below steps will give you all Guest users.

GUI
goto AAD > User > Add filter > User type > Guest > Export all users.

Powershell
Get-AzureADUser -All $true | Where-Object {$_.UserType -eq 'Guest'}

if you would like to validate specific guest ID exist or not then below command will be

Get-AzureADUser -SearchString "guest@gmail.com"


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.